标签: interface-builder

自定义按钮标题标签的文本会自动将其自身设置为默认值

我的自定义按钮包含在滑动时更新的值.但是当我点击它时,它不会保留该值,而是设置回在Interface Builder中设置的默认值,或者通过[button00 setText:@"default value" forState:UIControlStateNormal].

知道如何保持最新的更新值吗?

objective-c custom-controls interface-builder ios

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

在UILabel之后放置一个UIImage

我想要一个最大宽度为100的UILabel,然后是UIImage,我该如何在界面构建器中执行此操作?我希望如果文本较短,标签小于100但UIImage就在标签后面.

xcode interface-builder ios

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

如何使UIButton不可见,但如果按下它仍然可以工作?

我有一种情况,我需要使用Interface Builder将一个按钮添加到我的视图中,但不应该看到该按钮,但如果用户单击该按钮的位置,该按钮仍然可以调用其方法.

我已经尝试将不透明度设置为零,或者将按钮更改为"隐藏",但这两种策略都会导致一个完全不可见的按钮,但也无法按下,因为它无法按下.

有人有解决方案吗?

interface-builder uibutton ios

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

UIView 1px高度总是在UITableViewCell中出错

我有一个自定义TableviewCell Interfacebuilder,这是它的样子IB:

在此输入图像描述

注意标签下面的细白线.这是它在运行时期间应该看起来的样子.

层次结构UITableViewCell:

在此输入图像描述

我的问题是,在应用程序的运行时,线(这是第一个View下面的View)比例太大,我认为大约5px高度,甚至可能更大.

经过一些研究后我尝试了以下内容,但它不起作用.

cell.line.frame =CGRectMake(161,36,282,1/[[UIScreen mainScreen] scale]);
Run Code Online (Sandbox Code Playgroud)

objective-c interface-builder ios

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

Xcode 5中的标签栏图标太大

Tab Bar有问题.两天后,我打开了我的Xcode,图标Tab Bar已经加宽了.

我试图删除并插入一个新的TabBar控制器,但它没有解决问题.我也创建了一个新项目,但它有同样的问题.这个问题也反映在模拟器中.

有没有办法来解决这个问题?

我的TabBar控制器的屏幕截图

interface-builder storyboard ios7 xcode5

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

Xcode 5,Dynamic Prototype的自定义UITableViewCell类

我正在使用Xcode 5,并希望使用Apple推荐的最佳实践,包括动态原型单元和使用registerClass:forCellReuseIdentifier.

我创建了一个故事板并在其UITableView上放置了一个原型动态单元格.我已将单元格的类设置为ItemCell,并将重用标识符设置为ItemCell.

ItemCell类包含一个nameLabelIBOutlet,我通过拖动将其连接到原型单元格中的标签.

在ViewController中,我注册了ItemCell要用于ItemCell重用标识符的类:

- (void)viewDidLoad {
    [super viewDidLoad];

    [_tableView registerClass:[ItemCell class] forCellReuseIdentifier:@"ItemCell"];
}
Run Code Online (Sandbox Code Playgroud)

在tableView:cellForRowAtIndexPath中,我将单元格出列并设置nameLabel的属性.self.items是一个NSArray字符串.

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
        ItemCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ItemCell" forIndexPath:indexPath];
        cell.nameLabel.text = [self.items objectAtIndex:indexPath.row];

        return cell;
}
Run Code Online (Sandbox Code Playgroud)

所以:它是作为ItemCell创建的,但它并没有从故事板中加载它.我已经通过重写initWithStyle来确认这一点:reuseIdentifier和initWithCoder,以查看被调用的内容:

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        NSLog(@"NOT STORYBOARD");
    }
    return self;
}

-(id)initWithCoder:(NSCoder *)aDecoder {
    self = [super initWithCoder:aDecoder];
    if …
Run Code Online (Sandbox Code Playgroud)

xcode objective-c interface-builder ios

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

如何在右侧创建带图标的按钮?

我想在按钮标签旁边放一个图标.

问题:Interface Builder将按钮图像放在右侧.因此(x)旁边仍有一些空间.

谢谢你的帮助

在此输入图像描述

interface-builder ios

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

动画iOS xibs的约束

在iOS开发中使用xib时,我一直在阅读一些关于动画的帖子.我读到的大部分内容都是不对帧进行动画处理,而是对约束进行动画处理.我已经限制标签在启动时位于视图的中心,然后我将其设置为动画并显示登录文本字段(您看到的典型登录信息).

在此输入图像描述

我这样做了动画框架,当然,当我点击文本字段时,视图将原始约束应用于"我的标题"标签并将其推回到其原始中心位置.

在此输入图像描述

如何删除居中约束并添加新约束以从编程方式从顶部强制空间?

这是我的动画代码:

[UIView animateWithDuration: 0.8
                      delay: 1.0
     usingSpringWithDamping: 0.8
      initialSpringVelocity: 0.5
                    options: UIViewAnimationOptionCurveEaseOut
                 animations: ^{
                     self.titleLabel.frame = CGRectOffset(self.titleLabel.frame, 0, -self.view.frame.size.height/4.5);
                 } completion: ^(BOOL finished) {
                     if (finished)
                     {
                         [UIView animateWithDuration: 0.8
                                               delay: 0.3
                              usingSpringWithDamping: 0.8
                               initialSpringVelocity: 0.5
                                             options: UIViewAnimationOptionCurveEaseInOut
                                          animations: ^{

                                              self.userIdTextField.alpha = 1.0;
                                              self.userPasswordTextField.alpha = 1.0;
                                              self.loginButton.alpha = 1.0;

                                          } completion: ^(BOOL finished) {
                                          }];
                     }
                 }];
Run Code Online (Sandbox Code Playgroud)

animation objective-c interface-builder xib ios

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

ibtool无法构建 - 无法打开文件"Info.plist",因为没有这样的文件

在Xcode 7 beta 5中构建项目时出现以下错误:

Summary:
My project won't build, the following error is given:
LinkStoryboards
    cd /Users/lewis/Projects/MyApp/code/ios9
    export PATH="/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode-beta.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    export XCODE_DEVELOPER_USR_PATH=/Applications/Xcode-beta.app/Contents/Developer/usr/bin/..
    /Applications/Xcode-beta.app/Contents/Developer/usr/bin/ibtool --errors --warnings --notices --module MyApp --target-device iphone --minimum-deployment-target 8.0 --output-format human-readable-text --link /Users/lewis/Library/Developer/Xcode/DerivedData/MyApp-awistawhhrjdspbponhiluccszrg/Build/Products/Debug-iphonesimulator/MyApp.app /Users/lewis/Library/Developer/Xcode/DerivedData/MyApp-awistawhhrjdspbponhiluccszrg/Build/Intermediates/MyApp.build/Debug-iphonesimulator/MyApp.build/Storyboard\ ios7.storyboardc /Users/lewis/Library/Developer/Xcode/DerivedData/MyApp-awistawhhrjdspbponhiluccszrg/Build/Intermediates/MyApp.build/Debug-iphonesimulator/MyApp.build/Settings.storyboardc /Users/lewis/Library/Developer/Xcode/DerivedData/MyApp-awistawhhrjdspbponhiluccszrg/Build/Intermediates/MyApp.build/Debug-iphonesimulator/MyApp.build/TrackIt.storyboardc /Users/lewis/Library/Developer/Xcode/DerivedData/MyApp-awistawhhrjdspbponhiluccszrg/Build/Intermediates/MyApp.build/Debug-iphonesimulator/MyApp.build/UserList.storyboardc /Users/lewis/Library/Developer/Xcode/DerivedData/MyApp-awistawhhrjdspbponhiluccszrg/Build/Intermediates/MyApp.build/Debug-iphonesimulator/MyApp.build/Migration.storyboardc /Users/lewis/Library/Developer/Xcode/DerivedData/MyApp-awistawhhrjdspbponhiluccszrg/Build/Intermediates/MyApp.build/Debug-iphonesimulator/MyApp.build/Intro.storyboardc /Users/lewis/Library/Developer/Xcode/DerivedData/MyApp-awistawhhrjdspbponhiluccszrg/Build/Intermediates/MyApp.build/Debug-iphonesimulator/MyApp.build/YourMyApp.storyboardc /Users/lewis/Library/Developer/Xcode/DerivedData/MyApp-awistawhhrjdspbponhiluccszrg/Build/Intermediates/MyApp.build/Debug-iphonesimulator/MyApp.build/AddMeasurements.storyboardc


/* com.apple.ibtool.errors */
: error: The file “Info.plist” couldn’t be opened because there is no such file.
    Failure Reason: The file doesn’t exist.
    Underlying Errors:
        Description: The operation couldn’t be completed. No such file or directory …
Run Code Online (Sandbox Code Playgroud)

xcode interface-builder uistoryboard

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

如何更改在IBAction中注册的自定义UIButton的颜色?

我创建了一个名为RegistrationButton的自定义UIButton.我目前正在尝试允许用户在三个按钮之间进行选择.选择按钮后,背景颜色和文本将发生变化.以下是IBAction的外观:

  @IBAction func didTapBUtton(_ sender: UIButton) {


  switch sender {
    case studentButton:
        studentButton.selected()
        professionalButton.notSelected()
        entrepreneurhsip.notSelected()
        break
    case professionalButton:
        studentButton.notSelected()
        professionalButton.selected()
        entrepreneurhsip.notSelected()
        break
    case entrepreneurhsipButton:
        studentButton.notSelected()
        professionalButton.notSelected()
        entrepreneurhsip.selected()
        break
    default:
        break
    }
}
Run Code Online (Sandbox Code Playgroud)

这是我的自定义UIButton类的方法:

import UIKit

class RegistrationButton: UIButton {


override func awakeFromNib() {
    super.awakeFromNib()
    addBorder()

}

required init(coder:NSCoder) {
    super.init(coder:coder)!
}

func addBorder(){
    self.layer.borderColor = UIColor.white.cgColor
    self.layer.borderWidth = 1
}

func selected(){
     self.backgroundColor = .white

    self.setTitleColor(UIColor(red:67,green:204,blue:144,alpha:1), for: .normal)
}
func notSelected(){

    self.backgroundColor = UIColor(red:67,green:204,blue:144,alpha:1)


    self.setTitleColor(UIColor.white, for: .normal)
}
Run Code Online (Sandbox Code Playgroud)

}

但是,当我选择一个按钮时,所有背景都变为白色. 在此输入图像描述

interface-builder uibutton ibaction ios swift

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