[英]Table view controller with static cells
我的应用程序有问题,所以当我将此代码放入InfoViewController并运行该应用程序时,该视图似乎为空。我将一个表格视图设置为静态单元格,3个部分,每个部分的标题分组为样式,第一个单元格包含一个文本字段,该文本字段我已用作Google的搜索字段,一个搜索按钮,第二个和第三个单元格包含标签。我已将情节提要文件中的所有文本字段按钮和标签连接在一起,并且委托在文件所有者中。我是否应该实现其他方法? 谢谢你的建议。
#import <UIKit/UIKit.h>
@interface InfoViewController : UIViewController <UINavigationControllerDelegate>
@property (weak, nonatomic) IBOutlet UITextField *googleSearchTextField;
@property (weak, nonatomic) IBOutlet UIButton *searchButton;
@property (weak, nonatomic) IBOutlet UILabel *Label1;
@property (weak, nonatomic) IBOutlet UILabel *Label2;
-(IBAction)googleSearch;
@end
#import "InfoViewController.h"
@end
@implementation InfoViewController
@synthesize googleSearchTextField;
@synthesize searchButton;
@synthesize Label1;
@synthesize Label2;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.Label1.text = @“Label1”;
self.Label2.text = @“Label2”;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (BOOL)textFieldShouldReturn:(UITextField*)textField
{
[textField resignFirstResponder];
return YES;
}
-(IBAction)googleSearch
{
NSString *searchString=googleSearchTextField.text;
NSString *urlAdress = [NSString stringWithFormat:@"http://www.google.com/search?q=%@",
searchString];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlAdress]];
}
@end
您需要添加tableViewDelegate方法和TableViewDataSource方法
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.