我在製作滑塊應用程序。爲此,我寫了下面的代碼,但是當我按下build和go選項時,滑塊不移動。它在.h和.m文件中給出錯誤。iphone滑塊示例
SliderAppDelegate.h
#import <UIKit/UIKit.h>
@interface SliderAppDelegate : NSObject <UIApplicationDelegate>
{
UIWindow *window;
IBOutlet UISlider *slider;
IBOutlet UILabel *labelTxt;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) UILabel *labelTxt;
-(IBAction)changeSlider:(id)sender ;
@end
SliderAppDelegate.m
#import "SliderAppDelegate.h"
@implementation SliderAppDelegate
@synthesize window,labelTxt ;
- (void)applicationDidFinishLaunching:(UIApplication *)application
{
[window makeKeyAndVisible];
}
-(IBAction)changeSlider:(id)sender
{
labelTxt .text= [[NSString alloc] initWithFormat:@" Value %d ", (int)slider.value];
}
- (void)dealloc
{
[window release];
[label.Txt release];
[super dealloc];
}
@end
是否有這個代碼的任何問題?
您收到了什麼錯誤?嘗試刪除'.text'屬性之前的空格。並且請將所有代碼放在代碼標籤中。工具欄中有一個按鈕。 – FeifanZ 2011-04-25 10:26:05
沒有代碼標籤,你用4個空格縮進每行。 – 2011-04-25 10:30:04
哪個事件你用uislider在界面中設置? – GameLoading 2011-04-25 10:30:49