iOS中的每個對象都包含自己的tags
如果你感興趣使用標籤別的其他選項。
假設你button1.tag = 10,button2.tag = 20,button3.tag = 30
設置全局字符串在.h文件中
NSString *activecheck;
// assign the single method for all buttons in touchup inside method
- (IBAction)button_GetDeals:(UIButton*)sender {
switch (sender.tag)
{
case 10:
[email protected]"1";
break;
case 20:
[email protected]"2";
break;
case 30:
[email protected]"3";
break;
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([segue.identifier isEqualToString:@"secondviewcontrolleridentidiername"]) {
secondViewController *destViewController = segue.destinationViewController;
destViewController. buttontype = activecheck;
}
//這是你的第二個鑑於您的.m文件控制器
@interface secondViewController : UIViewController
@property (nonatomic, strong) NSString *buttontype;
@property (strong, nonatomic) IBOutlet UIWebView *webview;
@end
viewdidload
- (void)viewDidLoad
{
[super viewDidLoad];
if ([buttontype isEqualtoString:@"1"])
NSString *strURL = @"http://www.google.com";
NSURL *url = [NSURL URLWithString:strURL];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url];
[self.webiew loadRequest:urlRequest];
}
只是想跟着另外兩個條件Bing和雅虎....
簡單的人,你是用哪一種,故事板或XIB – 2015-03-25 04:51:17
@ Anbu.Karthik我用故事板 – 2015-03-25 04:52:14
設置按鈕標籤,如1 2 3分別。並在按鈕上按下發送該viewController具有webview。並且根據標記值,在webview – 2015-03-25 04:54:45