小编Hur*_*rkS的帖子

NSDictionary添加NULL键值

所以我正在创建一个NSDictionary,它正在提供要使用的方法数据,但是key数组中的一些键值并不总是用值填充..假设我有18个键(我这样做)..我可能只在一次通话中使用5,但在我的代码中的某些位置使用6或在所有18中使用.

我想知道的是如何将NULL值添加到这些键中,以便稍后当我查看键值对时,我可以看到我需要担心的哪些键以及哪些键可以忘记?所以问题是,如果我想在键中添加/ null,我该如何做而不会导致错误或认为它的数组结束为零.

这就是我目前所拥有的,但是当我尝试阅读NSDicionary时,它会给我一个错误的exe错误

NSDictionary*sendSeriesDictionary = [[NSDictionary alloc] init];

NSArray *keys = [NSArray arrayWithObjects:@"Code", @"MaID", @"MoID", @"SuID",@"SMID",@"Ye",@"KID",@"KBlID",@"KBk",@"CaID",@"Caer",@"Loe",@"Kepe",@"KTGroup",@"Cesc",@"LID",@"IN",@"LaID", nil];


NSArray *objects = [NSArray arrayWithObjects: NULL, manufactureIdString, modelIdString, subModelIdString, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, nil];

sendSeriesDictionary = [NSDictionary dictionaryWithObjects:objects forKeys:keys];
Run Code Online (Sandbox Code Playgroud)

只是为了让您知道密钥名称将被更改,这仅用于测试/示例如何执行此操作.

任何帮助将不胜感激.

iphone nsdictionary nsarray ios

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

检测UITableView中当前可见的最后一个UITableViewCell

我想知道是否有办法检测当前UITableViewCell是否是视图中的最后一个,然后当用户按下Enter键时,您将使用此代码滚动UITableView

int cellHeight = 44;
[finishingTableView setContentOffset:CGPointMake(finishingTableView.contentOffset.x,finishingTableView.contentOffset.y + cellHeight) animated:YES];
Run Code Online (Sandbox Code Playgroud)

我有一个带有自定义UITableViewCells的UITableView,每个UItableViewCell都有一个UITextfield,我正在以编程方式选择UITableViewCell,然后让单元格textfield成为第一个reasponder ...我想让用户一直打到UITableView的底部但是只有在要选择的下一个UITableViewCell不在视图时才开始滚动.

任何帮助,将不胜感激.

uitableview uitextfield ios

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

OR运算符在Objective C开关内

我想知道是否可能在ta开关声明案例中有一个(||)"或"或(&&)"和"运算符.

这就是我的想法.

switch (orientation) {
            case UIDeviceOrientationPortrait:
            {
                case (UIDeviceOrientationLandscapeLeft || UIDeviceOrientationLandscapeRight):
             }
            break;
//...
Run Code Online (Sandbox Code Playgroud)

如果有人可以帮助我,我会非常感激:)

iphone switch-statement ios

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

UIView backgroundColor与图像

我想知道如何将我的UIView的backgroundColor设置为滚动View Textured背景颜色.

这是我计划实现它的方式,但我只是不确定调用patternImage是什么.

jumpBarContainer.backgroundColor = [UIColor colorWithPatternImage:????]
Run Code Online (Sandbox Code Playgroud)

任何帮助将不胜感激.

iphone scrollview uiview ios

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

使uibutton脉动.

我试图通过在视图加载后来回改变alpha级别来制作一个有图像的uibutton缓慢脉动...

目前我这样做但它没有做任何事....

-(void)loopdyloop
{
    while ( myCount < 1000 )
    {

        [UIView animateWithDuration:3.0
                              delay:0.0f
                            options:UIViewAnimationCurveEaseOut
                         animations:^{


                             iconButton.alpha = 0.0;


                         } completion:^(BOOL finished) {
                             if (finished) {

                                 NSLog(@"animated");
                             }
                         }];


        [UIView animateWithDuration:3.0
                              delay:0.0f
                            options:UIViewAnimationCurveEaseOut
                         animations:^{


                             iconButton.alpha = 1.0;


                         } completion:^(BOOL finished) {
                             if (finished) {

                                 NSLog(@"animated");
                             }
                         }];




        myCount++;
    }

}
Run Code Online (Sandbox Code Playgroud)

从viewdidload方法调用此方法,

我知道但是我最好的尝试,如果你对如何实现这一点有任何想法,我将不胜感激.

iphone uibutton uiviewanimation ios

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

如何使用substringToIndex从NSString中捕获单个字符

我有一个有两个字符的NSString.

NSSring看起来像这样

FW

我使用此代码捕获第一个字符

NSString *firstStateString = [totInstStateString substringToIndex:1];
Run Code Online (Sandbox Code Playgroud)

这段代码返回F,我想知道如何使用substringToIndex将第二个字符返回到自己的字符串.

任何帮助,将不胜感激.

substring nsstring ios

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

为什么分析仪警告"未初始化的价值"?

我得到了这个分析仪警告

消息表达式中的参数是未初始化的值

在下面代码的第二行的第二个方括号下面有一个小橙色箭头

- (NSString *)base64EncodedString
{
    size_t outputLength;
    char *outputBuffer =
        NewBase64Encode([self bytes], [self length], true, &outputLength);



    NSString *result =
        [[[NSString alloc]
            initWithBytes:outputBuffer
            length:outputLength
            encoding:NSASCIIStringEncoding]
        autorelease];
    free(outputBuffer);
    return result;
}
Run Code Online (Sandbox Code Playgroud)

我不知道造成这种情况的原因我尝试了几件事,但从来没有这种类型的分析仪警告.

如何摆脱此分析仪警告?

objective-c clang-static-analyzer

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

HTML表格边框与单元格边框重叠

我有一个HTML表,我在ios应用程序的UIWebView中显示.该表看起来很甜,但表边框和或单元格边框与主表边框重叠.

这是一个例子. 在此输入图像描述

我正在使用CSS来设置这些边框的样式,并将其作为类添加到html中.这就是我的样式表.

<style type='text/css'>table.tdat{border-collapse:collapse;border-color:#000000; border-style:solid; border-width:1px;}td{padding:2px; font-family:Helvetica; color:black; font-size:12pt; height:15pt; text-align:right; vertical-align:top; white-space:nowrap;}tr.cta td{font-family:Arial; color:black; font-size:12pt; height:15pt; text-align:right;vertical-align:top;white-space:nowrap;border:1px solid #eeeeee;}tr.top td { border-top: thin solid black; }tr.bottom td { border-bottom: thin solid black; }tr.ax td:first-child { border-left: thin solid black; border-right: thin solid black;} </style>
Run Code Online (Sandbox Code Playgroud)

对于糟糕的格式化,这是来自NSString,我不是100%肯定的CSS格式,因为我只在制作ios应用程序时使用它.

然后我像这样使用那个css.

<table frame="box" class="tdat">
 <tr class="cta top ax">
  <td>Position:</td>
  <td width="20">1</td>
  <td width="20">2</td>
  <td width="20">3</td>
  <td width="20">4</td>
  <td width="20">5</td>
  <td width="20">6</td>
  <td width="20">7</td>
  <td width="20">8</td>
 </tr>
 <tr class="cta bottom ax">
  <td>Axis A:</td>
  <td>4</td> …
Run Code Online (Sandbox Code Playgroud)

html css html-table objective-c

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

如何从子视图访问ParentViewController方法?

我已经创建了一个方法来调用a UIViewControllersubview像这样加载它

cameraViewController = [[CameraViewController alloc] init];
        cameraViewController.view.frame = CGRectMake(0.0, 0.0, screenHeight, screenWidth);
        [cameraViewController drawCameraView:htmlProjID ProjectGUID:selectedProjGUID DoorGUID:cell.currentItem.doorGUID Info:nil doorName:cell.currentItem.doorDesc ViewName:@"Finishing"];
        [self.view addSubview:cameraViewController.view];
Run Code Online (Sandbox Code Playgroud)

我想知道是否有一种简单的方法可以camerViewController从原始的(子视图)访问方法UIViewController

objective-c subview uiviewcontroller uiview ios

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

将 NSData 字节顺序更改为小端

我试图找出更改我拥有的 NSData 对象的字节顺序的最佳方法。

这就是我创建它的方式

NSData *pillowData = [manufData subdataWithRange:NSMakeRange(5, 4)];
Run Code Online (Sandbox Code Playgroud)

这是枕头数据的输出

41543138
Run Code Online (Sandbox Code Playgroud)

这就是我想要的枕头数据在转换后的样子。

38315441
Run Code Online (Sandbox Code Playgroud)

基本上转换为小端。

objective-c endianness nsdata ios

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