【问题标题】:How to change size of PaintCode produced object如何更改 PaintCode 生成对象的大小
【发布时间】:2017-03-18 16:25:23
【问题描述】:

我是一个新手,正在努力制作我的第一个应用程序。我想通过从 UISlider 接收值来更改 PaintCode 制作的(贝塞尔路径)对象(?)的大小。谁能帮助我下面的代码有什么问题以及如何使它工作?

int heightOfBubble = 120;

- (IBAction)widthOfBubble:(id)sender {
NSLog(@"slider value = %f", self.slider.value);
[slider addTarget:self action:@selector(drawRect:) forControlEvents:UIControlEventValueChanged];
}


- (void)drawRect:(CGRect)rect {
label.text = [NSString stringWithFormat:@"%f", self.slider.value];
NSLog(@"slider value = %f", self.slider.value);
[BubbleText10 drawBubbleButtonWithText2:@"안개비 조명은 하예 흔들리는 내 몸을 감싸고~~ 술에 취에 비틀거리는 하~예 나의 모습 이제는 싫어~ 삐리비립" number:12 numberOfWidth:widthOfBubble numberOfHeight:heightOfBubble condition: NO];

我收到以下错误;

Mar 19 00:55:45  BubbleText03[44457] <Error>: CGContextRestoreGState: invalid context 0x0. Backtrace:
  <+[BubbleText10 drawBubbleButtonWithText2:number:numberOfWidth:numberOfHeight:condition:]+4941>
   <-[BubbleView drawRect:]+421>
    <-[UIApplication sendAction:to:from:forEvent:]+83>
     <-[UIControl sendAction:to:forEvent:]+67>
      <-[UIControl _sendActionsForEvents:withEvent:]+444>
       <-[UISlider endTrackingWithTouch:withEvent:]+255>
        <-[UIControl touchesEnded:withEvent:]+620>
         <-[UIWindow _sendTouchesForEvent:]+2747>
          <-[UIWindow sendEvent:]+4011>
           <-[UIApplication sendEvent:]+371>
            <__dispatchPreprocessedEventFromEventQueue+3248>
             <__handleEventQueue+4879>
              <__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__+17>
               <__CFRunLoopDoSources0+556>
                <__CFRunLoopRun+918>
                 <CFRunLoopRunSpecific+420>
                  <GSEventRunModal+161>
                   <UIApplicationMain+159>
                    <main+111>
                     <start+1>

提前非常感谢。

【问题讨论】:

    标签: iphone uislider addtarget


    【解决方案1】:

    @selector(setNeedsDisplay)代替@selector(drawRect:)


    文档:

    - (void)drawRect:(CGRect)rect;
    

    … 当视图首次显示或发生使视图的可见部分无效的事件时调用此方法。 您永远不应该自己直接调用此方法。要使您的部分视图无效,从而导致该部分被重绘,请改为调用setNeedsDisplaysetNeedsDisplayInRect: 方法。

    即使它说您自己直接并且您没有自己直接调用它,它仍然适用于您的情况。

    —PaintCode 支持

    【讨论】:

    • 它就像一个魅力!非常感谢你分享你的能力!!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-04
    • 2015-03-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多