IOS开发各种问题解决方法记录

1、判断一个view有没有superView

if ( [scrollView superviews] )

{
     [scrollView removeFromSuperView];
}
else
{
    [self.view addSubView:scrollView];

}

2、去除tableview的蓝色选中

吧tableview的Selection改为No Selection即可。

3、如何调用父view的controller里面的方法

[[self superview ].nextResponder  method];
[[[self superview ] nextResponder]  method];
[self.nextResponder method];
上面的都可以,看情况使用,使用的时候最好判断一下。

官方解释
UIView implements this method by returning the UIViewController object that manages it (if it has one) or its superview (if it doesn’t); UIViewController implements the method by returning its view’s superview; UIWindow returns the application object, and UIApplication returns nil.

4、如何隐藏tab bar controller 的tab bar

在Iphone编程中,很多人喜欢把Tab bar controller和Nav  一起混合使用,在点击了Tab bar上面的一个按钮切换到另一个view的时候,界面上的Tab Bar 没有消失.

导致view有部分的界面给遮挡了.所以需要把Tab Bar 给隐藏掉,隐藏代码如下:

self.newView = [[newViewController alloc] init];
newView.hidesBottomBarWhenPushed=YES;
[self.navigationController presentModalViewController:newView animated:YES];

在建立新的View的时候加入

newView.hidesBottomBarWhenPushed=YES;

即可使Tab Bar消失掉.

5、

UISearchBar 动作处理

  1. /*取消按钮*/  
  2. - (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar{  
  3.     [self doSearch:searchBar];  
  4. }  
  5.   
  6. /*键盘搜索按钮*/  
  7. - (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar{  
  8.     [searchBar resignFirstResponder];  
  9.     [self doSearch:searchBar];  
  10. }  
  11.   
  12. /*搜索*/  
  13. - (void)doSearch:(UISearchBar *)searchBar{  
  14.     ...  
  15. }  

UISearchBar上按钮的默认文字为Cancel,如果想改为其他文字请调用一下代码

  1. for(id cc in [searchtext subviews]){  
  2.    if([cc isKindOfClass:[UIButton class]]){  
  3.        UIButton *btn = (UIButton *)cc;  
  4.        [btn setTitle:@"取消"  forState:UIControlStateNormal];  
  5.    }  
  6. }  

注意:需要在.h文件种添加

<UISearchBarDelegate>,然后在.m文件种设置SearchBar的委托为:

self.SearchBar.delegate =self;   才可以生效。

6、控制Default.png图片的显示时间

直接在delegate里
sleep(想延长的秒数);

7、将UISearchBar 键盘上的Search键改成其他名字:  
UITextField *searchField = [[search subviews] lastObject];
[searchField setReturnKeyType:UIReturnKeyDone];

- (void)viewWillAppear:(BOOL)animated {

    [super viewWillAppear:animated];

    //NSLog(@"加载一次");

    //在此添加每次加载的时候要执行的内容

}


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值