小编Cha*_*son的帖子

Iphone UIButton不能在嵌套的UIViews中工作

这真是太简单了!我错过了一些东西,我试图解决它已经筋疲力尽了.希望有人可以提供帮助.

CharacterView.m中的Button可以工作,但是在CharacterMale.m中嵌套的按钮却没有.我没有使用IB一切都是按步骤完成的.什么会导致一个按钮工作,而另一个按钮不工作?

/////////////////////////////////////////////////////////////////////////////////
 CharacterController.m
/////////////////////////////////////////////////////////////////////////////////
#import "CharacterController.h"
#import "CharacterView.h"

@implementation CharacterController

- (id)init {
    NSLog(@"CharacterController init");
    self = [ super init ];
    if (self != nil) {
    }
    return self;
}

- (void)loadView {
    [ super loadView ];
    characterView = [ [ CharacterView alloc ] init];
    self.view = characterView;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}


- (void)dealloc {
    [super dealloc];
}

@end

/////////////////////////////////////////////////////////////////////////////////
 CharacterView.m
/////////////////////////////////////////////////////////////////////////////////

#import "CharacterView.h"
#import "CharacterMale.h"

@implementation CharacterView

- (id)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) …
Run Code Online (Sandbox Code Playgroud)

iphone uibutton uiviewcontroller uiview

11
推荐指数
2
解决办法
2万
查看次数

Iphone横向模式在加载新控制器时切换到Portraite模式

我的应用程序正确地以横向模式启动并且运行良好:

- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{
    if(interfaceOrientation == UIInterfaceOrientationPortrait)
        return NO;
    if(interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft )
        return YES; 
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
Run Code Online (Sandbox Code Playgroud)

并更新Info.plist

UIInterfaceOrientation = UIInterfaceOrientationLandscapeRight
Run Code Online (Sandbox Code Playgroud)

现在在我的主控制器中,我将一个ViewController换成另一个

characterController = [ [ CharacterController alloc ] init];
myCurrentViewController = characterController;
self.view =  myCurrentViewController.view ;
Run Code Online (Sandbox Code Playgroud)

它加载但方向处于纵向模式.如果我然后旋转了iPhone,它会将其更正为横向模式.任何想法如何在将新的viewController加载到我的mainController时保持横向方向?

iphone landscape orientation uiviewcontroller

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

Iphone对象C - 数据,对象和数组

所以我是一个Flash家伙,我正在尝试将以下代码转换为对象C:

    var slot:Object = new Object();
    slot.id         = i;
    slot.xPos       = 25*i;
    slot.yPos       = 25*i;
    slot.isEmpty    = False;
// push object to array
    arrGrid.push(slot);
Run Code Online (Sandbox Code Playgroud)

后来我可以覆盖:

arrGrid[0].isEmpty = True;
Run Code Online (Sandbox Code Playgroud)

我似乎无法找到在对象C中创建通用对象的引用.有人可以帮忙吗?

arrays iphone cocoa object objective-c

0
推荐指数
1
解决办法
5086
查看次数