小编sun*_*ppy的帖子

UIPickerView与Multiline UILabel

我目前正在开发一个程序,它可以从我的Core Data设置中动态填充选择器视图.我有一切都在数据方面工作,但我现在遇到的问题是在我的标签上格式化.

选择器在动作表中显示它自己的工具栏,工具栏的右侧有一个按钮.它的初始状态是可见2个刻度盘.按下按钮时,它会变为3个拨盘.

- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
{
    UILabel *pickerLabel = (UILabel *)view;

    CGSize limitSize = CGSizeMake(100.0f, 45.0f);
    CGSize textSize;
    CGRect labelRect;
    NSString *title = @"";


    switch (numberOfComponents){
        case 2:
        {
            ...gets strings from fetched data (varying length from 4 to 20+)
                    title = someString
        }
        case 3:
        {
            ...same as above but for the second set of data.
                    title = someString
        }           
    }


    textSize = [title sizeWithFont:[UIFont systemFontOfSize:14] constrainedToSize:limitSize lineBreakMode:UILineBreakModeWordWrap];
    labelRect = CGRectMake(0, 0, textSize.width, …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c uipickerview uikit uilabel

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

Python是否支持++?

可能重复:
Python中递增和递减运算符的行为

我是Python的新手,我对++ python感到困惑。我试过++ num但num的值没有改变:

>>> a = 1
>>> ++a
1
>>> print a
1
>>> print(++a)
1
Run Code Online (Sandbox Code Playgroud)

有人可以解释一下吗?如果Python支持++,为什么num保持不变。如果没有,为什么我可以使用++?

python

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

UIScrollView setContentSize使用自动布局中断视图

我在我的iPhone应用程序中使用自动布局并且有一个UIScrollView.当我的应用程序运行时,我需要在几个点上更改滚动视图的内容大小(因此设置内容大小viewWillAppear是没用的,因为我已经在其他地方看到了这个建议).

当我改变它时,我的子视图跳了起来,大概是因为它打破了自动布局约束.

那么如何在启用自动布局的情况下更改滚动视图内容大小?

谢谢.

iphone objective-c uiscrollview autolayout

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

调用NSTimer方法

我刚开始与计时器合作,iPhone需要一些支持.

我有一个方法如下所示,花费时间并更新UILabel我的userinterface.我也有一个NSTimer调用该方法一次一次(我只显示小时和分钟).这个工作得很好,除了应用程序的第一秒实时(据我所知,在timer调用方法之前需要一秒钟).

我想调用我的方法viewDidLoad,但我怎样才能提供正确的参数?或者有更好的方法吗?

// Timer for updating time
[NSTimer scheduledTimerWithTimeInterval:1.0f 
                                 target:self 
                               selector:@selector(updateTime:) 
                               userInfo:nil 
                                repeats:YES];   


-(void)updateTime: (NSTimer *) timer {

    currentTime = [NSDate date];
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    // display in 12HR/24HR (i.e. 11:25PM or 23:25) format according to User Settings
    [dateFormatter setTimeStyle:NSDateFormatterShortStyle];
    NSString *currentTimeString = [dateFormatter stringFromDate:currentTime];
    [dateFormatter release];

    timeLabel.text =  currentTimeString;
}
Run Code Online (Sandbox Code Playgroud)

欣赏任何可以指向正确方向的东西.

iphone objective-c nstimer ios

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

如何将背景图像放到iPhone的文本字段和文本视图中?

虽然我已经设置了背景图像属性UITextField.它不适用.我没有使用任何编码.我刚刚image.png使用Interface Builder 选择了一个文件作为背景图像.那么,怎么做呢?而且没有背景图片属性UITextView.那么,我该如何添加背景图像textView呢?谢谢您的帮助.

iphone xcode uitextfield uitextview ios

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

从其他 ViewController 中删除带有标记的视图

我一直试图从其他人调用的操作中删除我的视图,ViewController但我不知道该怎么做这是我的代码:

 + (Menu *)Mostrar:(UIView *)view{
     CGRect IMGFrame = CGRectMake( 5, 20, 70, 70 );
     UIButton *boton=[[UIButton alloc] initWithFrame:IMGFrame];
     [boton setBackgroundImage:[UIImage imageNamed:@"Logo_SuperiorBTN.png"] forState:UIControlStateNormal];
     [boton setBackgroundImage:[UIImage imageNamed:@"Logo_SuperiorBTN.png"] forState:UIControlStateSelected];
     [boton addTarget: self action: @selector(cerrarmenu:) forControlEvents: UIControlEventTouchUpInside];
     [boton setTag:899];
     [view addSubview: boton];
}
Run Code Online (Sandbox Code Playgroud)

那部分是从我MainViewController这样调用的

-(IBAction)menu:(id)sender{
    Menu *hudView = [Menu Mostrar:self.view];
}
Run Code Online (Sandbox Code Playgroud)

然后它显示视图,当我尝试使用按钮关闭它时它崩溃了

关闭菜单的代码是

+(void)cerrarmenu:(UIView *)view{
    for (UIView *subView in view) {
        if (subView.tag == 899) {
            [subView removeFromSuperview];
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

谢谢圣地亚哥

objective-c selector subview uiview ios

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

NSNumber如何获得最小的共同点?像0.375的3/8?

假如我有一个NSNumber,介于0和1之间,并且可以使用X/Y表示,在这种情况下如何计算X和Y?我不想比较:

if (number.doubleValue == 0.125)
{
    X = 1;
    Y = 8;
}
Run Code Online (Sandbox Code Playgroud)

所以我得到1/8的0.125

algorithm objective-c nsnumber ios

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