小编Dee*_*olu的帖子

每对的第二个对象必须是非零的

我在app上工作,当我调试我的代码时,它显示以下错误.

-(IBAction)addSelected:(id)sender
{

    NSString* emptyStr = @"";

    NSDictionary* traits = [NSDictionary dictionaryWithObjectsAndKeys:
        self.walletName.text,       @"alias",
        self.abc.text,     @"abc",
        self.field.text,     @"field",
        @"name,"                @"Type",
        nil];-------at this point it is showing thread recieved signal sigabrt
Run Code Online (Sandbox Code Playgroud)

在调试cosole中,它正是这个原因.'+ [NSDictionary dictionaryWithObjectsAndKeys:]:每对的第二个对象必须是非零的.或者,您是否忘记了终止参数列表? *第一次投掷筹码:

iphone cocoa-touch objective-c

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

在TextView中搜索字符串的出现次数

我有一个带有大文本的textview,我想在其中找到所有出现的字符串(搜索),每次按下搜索时,将textView滚动到当前事件的范围.

谢谢

xcode cocoa-touch objective-c ios

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

NSNetService工作正常,但无法获取主机名,解决会导致错误

我将Bonjour与NSNetService结合使用,以从iPhone发布服务器。一切正常,我可以浏览正在服务的页面等。但是,在iPhone上,我想显示主机名(即URL,例如“ myDevice.local。”),以便也可以输入在浏览器中手动寻址(对于缺少bonjour发现服务的客户端很有用)。我的理解是,调用方法[myNetService hostName]应该给我该地址。但是,此调用始终返回nil。我在某个论坛上读到我首先应该解析该服务,但是[myNetService resolve]和[myNetService resolveWithTimeout:10]都调用了委托方法

- (void)netService:(NSNetService *)sender didNotResolve:(NSDictionary *)errorDict;
Run Code Online (Sandbox Code Playgroud)

与错误

{
    NSNetServicesErrorCode = -72003;
    NSNetServicesErrorDomain = 10;
}
Run Code Online (Sandbox Code Playgroud)

这显然意味着它已经解决。同样,所有这些都在我可以使用该服务时发生。我也可以获取端口,域和服务类型。唯一奇怪的是,调用[myNetService地址]返回一个空数组。

我正在使用SDK 3.1.3。有人知道我会做错什么吗?

bonjour objective-c hostname nsnetservice ios

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

ALAsset时间戳返回错误的日期

我想获取图像的时间戳,我可以得到正确的纬度和经度值,但时间戳总是返回当前时间,而不是图像的EXIF时间.

ALAssetsLibraryAssetForURLResultBlock resultsBlock = ^(ALAsset *asset) {
    CLLocation *imageLoc = [asset valueForProperty:ALAssetPropertyLocation];
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"dd/MM/YY HH:mm:ss"];
    NSString *trailTime = [formatter stringFromDate:imageLoc.timestamp];
    NSLog(@"---+++ image TimeStamp: %@", trailTime);
    [formatter release];
Run Code Online (Sandbox Code Playgroud)

任何帮助表示感谢,谢谢

iphone objective-c assetslibrary alasset

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

如何将照片库或相机中的图像添加到我的Ipad应用程序?

我想从照片库中添加图像或使用相机添加到我的ipad应用程序中.我使用了与iphone相同的编码.但是应用程序崩溃了.我认为这不是从库添加图片到ipad应用程序的正确方法.如果有人知道请帮助我.

-(void)ctnPhotoSelection
{
    isMyCtView = YES;
    UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@""
                                                             delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil
                                                    otherButtonTitles:@"Take Photo With Camera", @"Select Photo From Library", @"Cancel", nil];
    actionSheet.actionSheetStyle = UIActionSheetStyleAutomatic;
    actionSheet.destructiveButtonIndex = 1; 
    [actionSheet showInView:self.view]; 
    [actionSheet release];
}

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
    if (buttonIndex == 0)
    {
        [self TakePhotoWithCamera];
    }   
    else if (buttonIndex == 1)
    {
        [self SelectPhotoFromLibrary];
    }

    else if (buttonIndex == 2)
    {
        NSLog(@"cancel");
    }
}

-(void) TakePhotoWithCamera
{
    [self startCameraPickerFromViewController:self usingDelegate:self];
}

-(void) SelectPhotoFromLibrary
{
    [self startLibraryPickerFromViewController:self usingDelegate:self]; …
Run Code Online (Sandbox Code Playgroud)

objective-c ipad ios

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

initWithNibName究竟做了什么?

theTestController = [[[CustomCell alloc]initWithNibName:@"CustomCell" bundle:[NSBundle mainBundle]]autorelease];
Run Code Online (Sandbox Code Playgroud)

我的猜测是它将加载CustomCell并将theTestController设置为所有者.如果是这样:

  1. 为什么在cellForRowAtIndexPath我看到的大多数示例代码中[[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner: theTestController options:nil]; 代替?

  2. [[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner: theTestController options:nil];和之间有什么区别theTestController = [[[CustomCell alloc]initWithNibName:@"CustomCell" bundle:[NSBundle mainBundle]]autorelease];

  3. 我试过替换[[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner: theTestController options:nil]; , theTestController = [[[CustomCell alloc]initWithNibName:@"CustomCell" bundle:[NSBundle mainBundle]]autorelease];我得到了错误.nil如果我使用后者,看起来仍然存在.

xcode objective-c uitableview

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

UITextField SecureTextEntry字段将键盘从数字键盘更改为通用键盘

我在IB中创建了一个textField.我已将键盘类型设置为Numeric PadIB.当我做secureTextEntry = YES-(void)textFieldDidBeginEditing:(UITextField *)textField方法,我的键盘从数字小到普通的键盘改变.我甚至尝试将键盘编程为数字编程,但它仍然没有改变.我这样设置了它

-(void)textFieldDidBeginEditing:(UITextField *)textField{
    if(textField == self.activationCodeTextField){
        self.activationCodeTextField.secureTextEntry = YES;
        self.activationCodeTextField.keyboardType = UIKeyboardTypeNumberPad;
    }
}
Run Code Online (Sandbox Code Playgroud)

仅供参考,我无法在IB中将textField设置为安全,因为我在文本字段中向用户显示了类似"4位"的提示文本,直到他开始在文本字段中输入为止.一旦他开始在文本字段中输入,我希望条目是一个安全的文本,以便它只显示*而不是他键入的实际字符.

能不能让我知道我在做什么错了?

我还有两个查询

  1. 我有一个textField,我有一些默认文本(如提示文本).我希望这个提示文本显示给用户,直到他开始输入的那一刻.当用户点击文本字段然后默认文本清除时,我不想清除此文本.但是,我希望显示此文本,直到他实际开始在键盘上键入内容的那一刻,然后必须清除默认值,然后在文本字段中显示实际键入的文本.是否有可能实现这一目标?

  2. 是否可以以编程方式将textfield的光标位置设置为第一个字符.这是必要的,因为我有一些默认文本(提示文本),光标位于文本的末尾.我希望光标位于文本的开头.如何以编程方式使这成为可能?

iphone cocoa-touch objective-c uitextfield

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

另一个"初始化使得指针来自整数而没有强制转换"的问题

我知道已经有很多线程以这种方式开始.我正在读,他们中的大多数都试图将一个int类型的值赋给NSInteger,我可以理解它会抛出一个错误.但是,我不认为这就是我这次正在做的事情.

我要做的是获取UISegmentedControl的selectedSegmentIndex的值,然后将其存储在NSInteger变量中.根据UISegmentedControl类参考,此属性也是NSInteger.

selectedSegmentIndex标识所选段的索引号(即最后触摸的段).

@property(非原子)NSInteger selectedSegmentIndex

所以这是代码:

- (IBAction) continueClick:(id)sender {
    NSInteger *playerCount = [sender selectedSegmentIndex];

    GameController.numberOfPlayers = playerCount;
}
Run Code Online (Sandbox Code Playgroud)

非常简单和基本.无论如何,据我所知.

iphone cocoa-touch objective-c uisegmentedcontrol

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

从NSData转换为NSImage

我在一个项目中工作,我从服务器获取结果,它就像数据形式一样意味着数字和字母表,所以我想将blob值更改为图像视图请帮助我,这对我来说太难了.

cocoa objective-c nsimage

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

如何将像"2011-06-25T11:00:26 + 01:00"这样的日期字符串转换为像iPhone一样长的字符串?

我需要将此字符串日期"2011-06-25T11:00:26 + 01:00"转换为长期值.

我试过这个

NSDateFormatter *df = [[[NSDateFormatter alloc] init] autorelease];

[df setTimeZone:[NSTimeZone timeZoneWithName:@"UTC"]];

[df setDateFormat:@"yyyy-MM-ddHH:mm:ssZ"];

NSDate *date = [df dateFromString:[time stringByReplacingOccurrencesOfString:@"T" withString:@""]];

[df setDateFormat:@"eee MMM dd, yyyy hh:mm"];

NSLog(@"time%@", time);
long lgTime =  (long)[date timeIntervalSince1970];
Run Code Online (Sandbox Code Playgroud)

但这不起作用.请帮我.

提前致谢.

iphone objective-c nsdate nsdateformatter

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

UIViewController无法识别方法

请帮我解决这个问题

我在名为firstviewcontroller的导航堆栈中有一个视图控制器

FirstViewController.h

@class ImperialPickerController;
@class FractionPickerController;
@class MetricPickerController;

@interface FirstViewController : UIViewController {

    UIView *pickerViewContainer;

    ImperialPickerController *ImperialPickerController;
    FractionPickerController *FractionPickerController;
    MetricPickerController *MetricPickerController;

    UIView *ImperialPickerViewContainer;
    UIView *FractionPickerViewContainer;
    UIView *MetricPickerViewContainer;

    UISegmentedControl *segmentedControl;

    NSInteger selectedUnit;
}

@property(nonatomic,retain) IBOutlet UIView *pickerViewContainer;

@property(nonatomic,retain) IBOutlet UIView *ImperialPickerViewContainer;
@property(nonatomic,retain) IBOutlet UIView *FractionPickerViewContainer;
@property(nonatomic,retain) IBOutlet UIView *MetricPickerViewContainer;

@property(nonatomic,retain) IBOutlet ImperialPickerController *ImperialPickerController;
@property(nonatomic,retain) IBOutlet FractionPickerController *FractionPickerController;
@property(nonatomic,retain) IBOutlet MetricPickerController *MetricPickerController;

@property(nonatomic,retain) IBOutlet UISegmentedControl *segmentedControl;

-(IBAction)toggleUnit;

@end
Run Code Online (Sandbox Code Playgroud)

FirstViewController.m

@implementation FirstViewController

@synthesize ImperialPickerController;
@synthesize FractionPickerController;
@synthesize MetricPickerController;
@synthesize ImperialPickerViewContainer;
@synthesize FractionPickerViewContainer; …
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch objective-c uiviewcontroller

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

是否启用和禁用触摸事件

如何启用和禁用触摸事件.

我有两个观点 - UIImageViewUIView.我想启用触摸UIImageView而不是触摸UIView.

有没有办法做到这一点?

iphone objective-c

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