UICatalog 随手记

来源:互联网 发布:nvslp监控软件下载 编辑:程序博客网 时间:2024/05/29 13:04

解决问题:

xCode problem: You don't have permission to save the file "iOS DeviceSupport" in the folder 'XCode'

 

sudo chmod 777 /Users/<Acount>/Library/Developer/Xcode

 

1:MainViewControl

他是继承 UITableViewController所以他自动带了tableview和很多table相关的代理

他使用了NSMutableArray + NSDictionary

viewDidLoad里面初始化所有的数据(建议一个NSMutableArray

viewWillAppear保证没有选中标志

        NSIndexPath *tableSelection = [self.tableViewindexPathForSelectedRow];     //  去掉以前选中的标志

[self.tableViewdeselectRowAtIndexPath:tableSelectionanimated:NO];


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section //设立section里面行数

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView  //设立section数

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section //设立section标题



- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath //设立行内容

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath // 设定点击的反应


        UIViewController *targetViewController = [[self.menuListobjectAtIndex: indexPath.row]objectForKey:kViewControllerKey];

[[selfnavigationController]pushViewController:targetViewControlleranimated:YES]; // 切换viewcontrol


self.title = 。。。 // 设置自己view control的标题






2: Button


  1. typedef enum {  
  2.     UIButtonTypeCustom = 0,           // no button type   自定义,无风格  
  3.     UIButtonTypeRoundedRect,          // rounded rect, flat white button, like in address card 白色圆角矩形,类似偏好设置表格单元或者地址簿卡片  
  4.     UIButtonTypeDetailDisclosure,//蓝色的披露按钮,可放在任何文字旁  
  5.     UIButtonTypeInfoLight,//微件(widget)使用的小圆圈信息按钮,可以放在任何文字旁  
  6.     UIButtonTypeInfoDark,//白色背景下使用的深色圆圈信息按钮  
  7.     UIButtonTypeContactAdd,//蓝色加号(+)按钮,可以放在任何文字旁  
  8. } UIButtonType;  

建立button两种方式:

1:通过alloc+initwithframe来建立

UIButton *button = [[UIButtonalloc]initWithFrame:frame];


2:通过buttonWithType来建立

UIButton *button = [[UIButton buttonWithType:UIButtonTypeCustom] retain];

roundedButtonType = [[UIButtonbuttonWithType:UIButtonTypeRoundedRect]retain];



3: UITextField


typedefenum {

    UITextBorderStyleNone,

    UITextBorderStyleLine,

    UITextBorderStyleBezel,       // 普通边框

    UITextBorderStyleRoundedRect  // 圆角

} UITextBorderStyle;



通过alloc+initwithframe来建立

             textFieldRounded.returnKeyType =UIReturnKeyDone;

     textFieldRounded.clearButtonMode = UITextFieldViewModeWhileEditing;// has a clear 'x' button to the right

    为了在按done 以后 消掉键盘:

    设置一个textFieldRounded.delegate 

    并且:

          

- (BOOL)textFieldShouldReturn:(UITextField *)textField

{

// the user pressed the "Done" button, so dismiss the keyboard

[textFieldresignFirstResponder];

returnYES;

}

     













原创粉丝点击