小编mbm*_*414的帖子

iOS: Simple AutoLayout with 1 Label and 3 Buttons

I'm playing around with AutoLayout and am really banging my head against the wall for what seems like it ought to be an extremely simple solution.

  1. I've got a vertical column of controls: 1 label and 3 buttons.
  2. I want the label to be 40 pixels(points) tall and auto-size its width based on the width of its superview (standard spacing on left, top and right).
  3. I want the 3 buttons to line up vertically below that label.
  4. I would like …

ios autolayout

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

展开标签并转换为Int()

我想在这里做这个教程.我是初学者,这将是我的第一个iOS应用程序时期:

http://www.ioscreator.com/tutorials/calculator-tutorial-in-ios8-with-swift

这是我的代码:

导入UIKit

class ViewController: UIViewController {

    var isTypingNumber = false
    var firstNumber = 0
    var secondNumber = 0
    var operation = ""

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


    @IBOutlet weak var calculatorDisplay: UILabel!

    @IBAction func numberTapped(sender: AnyObject) {

        var number = sender.currentTitle

        if isTypingNumber {
            calculatorDisplay.text = calculatorDisplay.text! + number!! …
Run Code Online (Sandbox Code Playgroud)

optional ios swift

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

Android:使用LeadingMarginSpan在textview中显示项目符号列表?

我想在textview中显示项目符号列表.我可以使用子弹,但子弹不是很有吸引力,似乎没有办法定制它.我想使用默认项目符号(•)作为我的项目符号列表.有没有办法使用LeadingMarginSpan来获得我想要的效果?基本上,如果线条以子弹开头,我希望它与左边对齐,但是如果线条太长以至于它断开那么下一行向下的文本(断开的文本)应该缩进到与之后的文本相同的级别要点.

* for example
instead of this

* for example
  should look like this
Run Code Online (Sandbox Code Playgroud)

我目前的代码:

String[] bulletpoint = {some array of strings};
CharSequence allText = "";

for (int i = 0; i < bulletpoint.length; i++) {
    String text = bulletpoint[i];
    SpannableString s = new SpannableString(text + "\n");
    s.setSpan(new LeadingMarginSpan(BulletSpan.STANDARD_GAP_WIDTH) {
        @Override
        public int getLeadingMargin(boolean first) {
            return 0;
        }
        @Override
        public void drawLeadingMargin(Canvas c, Paint p, int x, int dir, int top, int baseline, int bottom, CharSequence text, int start, …
Run Code Online (Sandbox Code Playgroud)

java android textview android-xml

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

drawRect:不工作

我想UIView在屏幕上放置一些"手柄" .

所以,我正在创建更多的UIViews,在UIView框架矩形的每个角落都有一个,我只想绘制一个"填充"矩形的圆圈,这个矩形是"手柄"的框架UIView.

这就是我的意思:

我如何创建"HandleView":

CGPoint upperLeft = CGPointMake([[self viewToMove] frame].origin.x - 5, [[self viewToMove] frame].origin.y - 5);
HandleView *uL = [[HandleView alloc] initWithFrame:CGRectMake(upperLeft.x, upperLeft.y, 10, 10)];
[self setUpperLeftHandle:uL];
[uL release];
[[self view] addSubview:[self upperLeftHandle]];
Run Code Online (Sandbox Code Playgroud)

drawRect:for HandleView:

- (void)drawRect:(CGRect)rect {
   // Drawing code
   CGContextRef context = UIGraphicsGetCurrentContext();
   [[UIColor orangeColor] set];
   CGContextFillEllipseInRect(context, [self frame]);
}
Run Code Online (Sandbox Code Playgroud)

我得到的只是一组黑色矩形,我放置了HandleViews.我不确定为什么它们是黑色的,但我可以通过改变[HandleView backgroundColor]属性来改变颜色.不过,我不能在这个观点上得到任何东西.呼叫setNeedsDisplay似乎没有任何区别.

此外,drawRect:调用方法IS,因此那里的代码存在问题,可能不在其他任何地方.

我已经有一段时间了,因为我搞定了自定义绘图,但我不记得这很难.

我错过了什么?

谢谢!!!

更新:

修改后的代码:

- (id)initWithFrame:(CGRect)frame {
    if …
Run Code Online (Sandbox Code Playgroud)

iphone sdk objective-c ios

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

标签 统计

ios ×3

android ×1

android-xml ×1

autolayout ×1

iphone ×1

java ×1

objective-c ×1

optional ×1

sdk ×1

swift ×1

textview ×1