如何让uiviewcontroller刷新上部不遮挡状态栏

//添加监听事件
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
//监听回调
#pragma mark - keyboard
- (void)keyboardWillShow:(NSNotification*)notification {
CGRect frame = self.view.
frame.origin.y -= 166;
//frame.size.height +=216;
// Shrink view's inset by the keyboard's height, and scroll to show the text field/view being edited
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationCurve:[[[notification userInfo] objectForKey:UIKeyboardAnimationCurveUserInfoKey] intValue]];
[UIView setAnimationDuration:[[[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] floatValue]];
self.view.frame =
[UIView commitAnimations];
- (void)keyboardWillHide:(NSNotification*)notification {
CGRect frame = self.view.
frame.origin.y += 166;
//frame.size.height -=216;
//self.view移回原位置
// Restore dimensions to prior size
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationCurve:[[[notification userInfo] objectForKey:UIKeyboardAnimationCurveUserInfoKey] intValue]];
[UIView setAnimationDuration:[[[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] floatValue]];
self.view.frame =
[UIView commitAnimations];
阅读(...) 评论()主题 : UIViewController的透明背景挡住了按钮
级别: 新手上路
可可豆: 63 CB
威望: 63 点
在线时间: 18(时)
发自: Web Page
来源于&&分类
UIViewController的透明背景挡住了按钮&&&
是这样的,点某个按钮会addSubView一个UIViewController这个UIViewController是透明背景clearColor,但我加了一个背景图的坐标是 x=100 y=0但左边的空白区域下面的东西还是不可以点,请问要怎么做才能完全去掉背景,让背景的透明空白区域下面的按钮可以点?谢谢.
级别: 骑士
可可豆: 382 CB
威望: 384 点
在线时间: 485(时)
发自: Web Page
所以就是說你按鈕按下去之後 新增出來的view 雖然說是透明的 但是他就是佔了一塊畫面位置 而那個被佔的畫面位置剛好有按鈕對吧要不就把view縮小 縮到不會擋到按鈕要不就 [view bringSubviewToFront:button];這樣試看看
發問前請多想想 問題是否能夠從Google搜尋找到 或是從Stackoverflow找到
级别: 新手上路
可可豆: 63 CB
威望: 63 点
在线时间: 18(时)
发自: Web Page
回 1楼(tom) 的帖子
谢谢,但没办法把那个按钮放到面板上面来,如图:下面的一堆按钮都是在另一个uiview里的红色区域下面的都点不了,我以为是被图遮住了,我把上面的图分开两个,并往右移了不知道有什么办法没有
图片:QQ.jpg
级别: 骑士
可可豆: 382 CB
威望: 384 点
在线时间: 485(时)
发自: Web Page
你可以程式檢查你view的順序[self.view subviews];self.view 是你的viewController最上層的view, 這樣才會列出所有元件只有那塊被擋到一定是被某個view給擋住才會按不了 目前看來很有可能是那個像臉書登入視窗的view 只是就你說的那塊是透明的我想你那應該是那登入view套backgroundimage要是我個人的話 我會請美工把那塊透明給修掉然後上面那個圓圈(Name,Career) 如果是跟圖一起的話 請美工分開 另外做個imageView不然的話就還是我講的 想辦法取得edwards那按鈕的reference然後還是一樣bringToFront, 然後[self.view subviews]; 檢查順序
發問前請多想想 問題是否能夠從Google搜尋找到 或是從Stackoverflow找到
关注本帖(如果有新回复会站内信通知您)
9*6-8 正确答案:46
发帖、回帖都会得到可观的积分奖励。
按"Ctrl+Enter"直接提交
关注CocoaChina
关注微信 每日推荐
扫一扫 浏览移动版第一种方式:通过代码方式创建视图控制器UIViewController,添加子视图,需要留意创建视图的size,如果是为0是看不到的第二种方式:xib或storyboard方式创建视图控制器UIViewController,需要留意xib是否与视图变量之间建立的关系,没有建立关系子视图是添加到视图view中,但是就是不能系显示。如图:UIViewController中无法显示子UIViewController中的view - 为程序员服务
UIViewController中无法显示子UIViewController中的view
我的程序结构如下图
Window-&rootViewController-&mainViewController.view-&subViewController.view
当我把subViewController.view添加到mainViewController.view中的时候无法显示为我指定的位置,height变成了0.
尝试在mainViewController中创建一个UIView并显示,可以正常显示。
因此,我尝试将subViewController的view重载,问题解决
重载方法如下:
1.新建一个继承于UIView的类(GRView)
2.在subViewController的viewDidLoad方法中添加如下代码
self.view = [GRView alloc]initWithFrame:CGRectZero];
又一个 WordPress 站点
原文地址:, 感谢原作者分享。
您可能感兴趣的代码}

我要回帖

更多关于 uiviewcontroller横屏 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信