小编neu*_*ino的帖子

即使我在主线程中更新它,UIButton标题文本也不会更新

UIButton当用户点击它时,我正在尝试以编程方式更改我创建的标题.所以,这是我创建的代码UIButton:

myButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, parentView.frame.size.width, parentView.frame.size.height)];
[myButton setBackgroundColor:[UIColor blackColor]];
[myButton setAlpha:0.7];
[myButton setTitle:@"Hello" forState:UIControlStateNormal];
[myButton addTarget:self action:@selector(userClicked:) forControlEvents:UIControlEventTouchUpInside];

[parentView addSubview:myButton];
Run Code Online (Sandbox Code Playgroud)

而且,在我的userClicked:方法中,我做:

-(void) userClicked:(UIButton*)button
{
    NSLog(@"USER CLICKED!!!");
    if ([NSThread isMainThread])
    {
        NSLog(@"is main thread");
    }

    [button setTitle:@"Bye" forState:UIControlStateHighlighted];
    [button setTitle:@"Bye" forState:UIControlStateNormal];
    [button setTitle:@"Bye" forState:UIControlStateSelected];

    [self someLengthyComputation];
}
Run Code Online (Sandbox Code Playgroud)

奇怪的是我可以看到打印的日志消息:

USER CLICKED!!! 
isMainThread
Run Code Online (Sandbox Code Playgroud)

但是,按钮的标题不会改变!我究竟做错了什么?

编辑:设置几个州的标题也不起作用.

EDIT2:如果我在Xcode的调试器窗口中打印按钮的描述,它会显示正确的标题!

Printing description of button->_titleView:
<UIButtonLabel: 0xa4c9310; frame = (95 216; 130 22); text = 'Bye'; clipsToBounds = YES; opaque …
Run Code Online (Sandbox Code Playgroud)

objective-c uibutton ios ios7 xcode5

40
推荐指数
10
解决办法
4万
查看次数

UISegmentedControl界限

我想将以下方面提供给UISegmentedControl:

在此输入图像描述

请注意灰色背景视图和分段控件非选定项目的白色背景.

但是,如果我给我的UISegmentedControl一个白色背景,我得到以下内容:

在此输入图像描述

注意UISegmentedControl周围的白色方角.我该怎么做才能避免那个方角?

先感谢您,

编辑:如果我更改UISegmentedControl的图层的角半径,如onegray所示,结果更好,但不完美(注意右边的白线):

在此输入图像描述

iphone uisegmentedcontrol ios7

18
推荐指数
2
解决办法
6034
查看次数

尝试在将iOS应用程序上载到AppStore之前验证它时出错

当我尝试使用管理器使用应用程序验证存档时,在将其上传到App Store之前,我收到以下错误:"由于一般错误,此时无法处理lookupPurpleSoftwareVersions请求".有没有人收到这条消息?这是由于Apple开发人员门户问题吗?

谢谢,

xcode app-store ios6

13
推荐指数
2
解决办法
9521
查看次数

在故事板中设计UICollectionViewCell

我从未使用过UICollectionViewControllers,我认为它们与UITableViewControllers 有些相似,但令我惊讶的是,我无法UICollectionViewCell像使用自定义UITableViewCells 那样将UI元素添加到自定义s中.

实际上,我可以在Interface Builder中添加标签,按钮等,但是当我运行应用程序时,单元格显示为空.

我已经注册了在细胞类viewDidLoad通过调用方法(void)registerClass:(Class)cellClass forCellWithReuseIdentifier:(NSString *)identifier,我已经检查了我回国的有效实例UICollectionViewCell的(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath方法.

我究竟做错了什么?

objective-c ios uicollectionview uicollectionviewcell

9
推荐指数
1
解决办法
8329
查看次数

在UITabBarItem上使用自定义选定图像和未选定图像

我正在尝试将自己的图像设置为UITabBarItem上的选定图像和未选择图像,但没有运气.我在视图控制器viewDidLoad和viewWillAppear方法中尝试了以下代码,但都不起作用:

[self.tabBarItem setFinishedSelectedImage:[UIImage imageNamed:@"on_rojo"] withFinishedUnselectedImage:[UIImage imageNamed:@"on"]];
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?我也看到了:iOS 5中:UITabBarItem setFinishedSelectedImage:withFinishedUnselectedImage:不工作/忽略,但我已经建立了我的UITabBarController在IB,而不是编程.这是问题吗?

先感谢您,

objective-c uitabbarcontroller uitabbar ios

4
推荐指数
1
解决办法
7811
查看次数

没有可见的dismissModalViewControllerAnimated接口:完成

我有一个使用该方法的UIViewController派生类dismissModalViewControllerAnimated:(BOOL),如下所示:

[self dismissModalViewControllerAnimated:YES];
Run Code Online (Sandbox Code Playgroud)

由于编译器抱怨说该方法已被弃用,我已将其更改为建议的替换dismissModalViewControllerAnimated:completion:,如下所示:

[self dismissModalViewControllerAnimated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)

但现在,在该行代码中出现错误,说"没有可见的@interface for 声明选择器 dismissModalViewControllerAnimated:completion:

我看不出有什么问题,因为两个方法都在UIViewController.h中定义,而我的类派生自该类.

我究竟做错了什么?

先感谢您

objective-c uiviewcontroller ios6

2
推荐指数
1
解决办法
2442
查看次数