[英]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.