小编Sam*_*Sam的帖子

如何在UIAlertView中创建自定义UIButton

所以我试图在UIAlertView中嵌入一个可切换的(是一个单词吗?)"不再显示这个"按钮,但是我遇到了一些我似乎无法绕过的麻烦.

这是我迄今为止的非工作代码......

编辑:我添加了按钮的方法,并对原始代码进行了一些更改.现在我按下按钮对印刷机作出反应,但结果是崩溃.有帮助吗?

if (![[NSUserDefaults standardUserDefaults] objectForKey:@"disclaimer"]){


UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"DISCLAIMER" 
                                                message:@"This program is a blah blah"
                                               delegate:self 
                                      cancelButtonTitle:nil
                                      otherButtonTitles:@"I Agree", nil];

UILabel *alertLabel = [[UILabel alloc] initWithFrame:CGRectMake(30, 230, 260, 50)];
alertLabel.backgroundColor = [UIColor clearColor];
alertLabel.textColor = [UIColor whiteColor];
alertLabel.text = @"Do not show again";
[alert addSubview:alertLabel];
[alertLabel release];

//declared alertCheckboxButton in the header due to errors I was getting when referring to the button in the button's method below
alertCheckboxButton = [UIButton buttonWithType:UIButtonTypeCustom];
alertCheckboxButton.frame = CGRectMake(200, 247, …
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch objective-c uibutton uialertview

7
推荐指数
1
解决办法
5129
查看次数

无法在视图之间读取NSUserDefaults数据

免责声明:主要菜鸟

我正在编写一个算术闪存卡应用程序作为学习项目.我有一个UITabViewController,底部的标签栏可以在几个不同的视图之间切换.一切正常,直到我尝试在Settings视图控制器中设置NSUserDefault布尔值并尝试在Flashcards视图控制器中读取这些值.

设置视图有一个开关,用于启用/禁用每个操作符(加法,减法等),如果启用了此类操作,则闪卡视图应随机显示闪存卡.

我相信我的错误是我不理解数据封装,对象等的关键概念.我很感激任何帮助.

这是"设置"视图控制器.我甚至不确定如何将代码放入此论坛,所以这可能是一个可笑的时刻......这里是:

//  settings_flashcards.h

#import <UIKit/UIKit.h>
@interface settings_flashcards : UIViewController {
UISwitch *additionSwitch;
UISwitch *subtractionSwitch;
UISwitch *multiplicationSwitch;
UISwitch *divisionSwitch;
}

@property (nonatomic,retain) IBOutlet UISwitch *additionSwitch;
@property (nonatomic,retain) IBOutlet UISwitch *subtractionSwitch;
@property (nonatomic,retain) IBOutlet UISwitch *multiplicationSwitch;
@property (nonatomic,retain) IBOutlet UISwitch *divisionSwitch;

@end
Run Code Online (Sandbox Code Playgroud)

和...

/  settings_flashcards.m

#import "settings_flashcards.h"

@implementation settings_flashcards

@synthesize additionSwitch;
@synthesize subtractionSwitch;
@synthesize multiplicationSwitch;
@synthesize divisionSwitch;

- (void)viewDidLoad {

[additionSwitch addTarget:self action:@selector(additionSwitchFlipped) forControlEvents:UIControlEventValueChanged];
[subtractionSwitch addTarget:self action:@selector(subtractionSwitchFlipped) forControlEvents:UIControlEventValueChanged];
[multiplicationSwitch addTarget:self action:@selector(multiplicationSwitchFlipped) forControlEvents:UIControlEventValueChanged];
[divisionSwitch addTarget:self action:@selector(divisionSwitchFlipped) forControlEvents:UIControlEventValueChanged];
[super viewDidLoad]; …
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch objective-c

3
推荐指数
1
解决办法
1450
查看次数

标签 统计

cocoa-touch ×2

iphone ×2

objective-c ×2

uialertview ×1

uibutton ×1