2011-10-04 84 views
0

我非常喜欢新手机,我希望在一行中显示四个图像,例如tabbar,如果用户单击任何图像,我想在iPhone中显示另一个屏幕。如何在点击iPhone中的图像时导航到其他屏幕

任何人都可以告诉我我该怎么做,如果可能的话,请告诉我在哪些文件中我必须编写代码来实现此要求。

+0

你的问题不能直接回答,因为没有一个做到这一点的方式。也没有一个你可以编写代码的文件。我从[你的第一个iOS应用程序](https://developer.apple.com/library/ios/#documentation/iPhone/Conceptual/iPhone101/Articles/00_Introduction.html)开始申请,然后通过[ViewController编程](https://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/Introduction/Introduction.html) – rckoenes

+0

我添加了四个图像现在我需要给这些四个图像的一些背景颜色喜欢像一个标签栏,所以请任何人告诉我如何获得整个行的背景颜色 –

回答

2

尝试这个

在viewDidLoad中

CGRect myImageRect = CGRectMake(10.0f, 5.0f, 80.0f, 95.0f); 

UIImageView *imageView = [[UIImageView alloc] initWithFrame:myImageRect]; 

[imageView.layer setBorderColor: [[UIColor blackColor] CGColor]]; 
[imageView.layer setBorderWidth: 2.0]; 
imageView.opaque = YES; // explicitly opaque for performance 
[self.view addSubview:imageView]; 

UIButton *newbutton1 = [[UIButton alloc] init]; 
[newbutton1 setFrame:myImageRect]; 
[newbutton1 addTarget:self action:@selector(myMethod:) 
    forControlEvents:UIControlEventTouchUpInside]; 
[self.view addSubview:newbutton1]; 


//Method on Button Click 
-(void)myMethod:(id)sender { 
    //Button is pressed 
} 
0

制作一些xib文件并构建您的用户界面。

您需要将其他屏幕设置为IBOutlets,并在点击按钮后执行切换视图的操作。

您可以为UIButton设置图像背景。

试试吧,它不是那么大的问题。

0

安排手动4个图像在乌尔屏幕

例如

UIImageView *myImageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 100, 100)]; 

myImageView.image = [UIImage imageNamedWith:@"ur image.png"]; 

UIGestureRecognizer *recognizer1 = [[UITapGestureRecognizer alloc] initWithTarget:self 
          action:@selector(showtheUI:)]; 

    [myImageView addGestureRecognizer:recognizer1]; 

    recognizer1.delegate = self; 

[recognizer1 release]; 

[self.view addSubView:myImageView ]; 

} 

//this method will trigger when u tapped the 1st image 
-(void)showtheUI(UIImageViee *)sender{ 


} 

创建第二ImageView的像

UIImageView *myImageView = [[UIImageView alloc] initWithFrame:CGRectMake(120, 10, 100, 100)]; etc 

或使用for循环以创建4个图像浏览。根据我值设置框架

0

您需要创建自定义表或更多的东西要用于将创建图像

的网格类型,你需要使用下面的东西用 的TableView

  • 定制的UITableViewCell图像
  • HJCache异步图像加载的
  • 阵列。
-1

你可以在你的图像添加按钮和手柄键按钮的事件导航到其他屏幕

相关问题