我想为表格视图的每个单元格设置不同的图像.我不知道怎么做 - 请帮帮我.
我正试图UITextView在应用程序启动时显示一个字符串.我有一个UIView和一个UITextView在我的界面,一个插座,myText连接到UITextView.它似乎没有工作,我不能说为什么....
这是有问题的代码:
MainView.h
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
@interface MainView : UIView {
IBOutlet UITextView *myText;
}
@end
Run Code Online (Sandbox Code Playgroud)
MainView.m
@implementation MainView
-(id) initWithCoder:(NSCoder *)coder {
if ((self = [super initWithCoder:coder]) != nil)
{
NSLog(@"initWithCoder executed");
myText.text = @"Hello, World!";
}
return self;
}
@end
Run Code Online (Sandbox Code Playgroud)
该NSLog()打印信息,所以我认为这myText.text确实是设置为@"Hello World",但这并没有反映在我的UITextView.这里挂了哪里?如果它有帮助,这是我的实际应用程序的简化版本,当我将其myText.text = @"Hello, World!";放入响应按钮按下的方法时,更改将反映在文本视图中.
如何创建NSDate今天的日期以及分别为5,0和0的小时,分钟和秒?即日期将是07/02/2010 05:00:00
是否可以指定NSDictionary一个NSMutableDictionary?例如,
NSMutableDictionary * root = AppDelegate.data;
Run Code Online (Sandbox Code Playgroud)
这里AppDelegate.data是一个NSDictionary.
我想通过类似UIButtonType的UIButton类添加一个新的自定义:
enum {
UIButtonTypeMatteWhiteBordered = 0x100
};
@interface UIButton (Custom)
+ (id)buttonWithType:(UIButtonType)buttonType;
@end
Run Code Online (Sandbox Code Playgroud)
是否有可能以super某种方式获得该重写方法的实现?
+ (id)buttonWithType:(UIButtonType)buttonType {
return [super buttonWithType:buttonType];
}
Run Code Online (Sandbox Code Playgroud)
上面的代码无效,因为在此上下文中super引用UIControl.
我正在开发一款需要检测滑动手势的应用程序(实际上是一款游戏).当我在我的图像视图上滑动时,需要更改图像视图的图像,但不幸的是它没有按预期工作.
当我将滑动手势对象添加到self.view时,每当我将手指滑动到视图中的任何位置时,都会执行所需的操作,但我希望仅当我在imageView上滑动手指时才执行此操作.
另一方面,当我尝试将滑动手势添加到图像视图时,它不响应手势事件.
如果您有解决此问题的解决方案,请回复!
提前致谢!
我正在使用PHP类连接到数据库.我无法解决问题 - 请帮我解决这个问题.
我有一个功能:
function getCampus($cm_id) //returns campus name
{
$this->query = "select cm_name from campus where cm_id = ".$cm_id.";";
$rd = $this->executeQuery();
@$data = $rd->fetch_assoc();
}
Run Code Online (Sandbox Code Playgroud)
当我@从中移除时 @$data,它不起作用.请帮帮我:解释一下替代方式是什么.谢谢.
当我选择一个表视图的行时,它变为蓝色.当我触摸它时,我希望行不会改变颜色.我怎样才能做到这一点?
我需要从中得到一个long值NSString.
例如,我有这个:
NSString *test = @"5437128";
Run Code Online (Sandbox Code Playgroud)
我需要:
long myLong = 5437128;
Run Code Online (Sandbox Code Playgroud)
我如何从中获得这个long价值NSString?
谢谢,它会对我有所帮助!
我正在阅读它所说的内存管理规则
- (void)printHello {
NSString *string;
string = [[NSString alloc] initWithString:@"Hello"];
NSLog(@"%@", string);
[string release];
}
Run Code Online (Sandbox Code Playgroud)
你有所有权并且必须释放string,但我很好奇@"Hello".@" "是创建和的语法NSString,它是一个对象.那不是泄露了吗?
objective-c ×6
cocoa-touch ×4
ios ×4
cocoa ×2
nsstring ×2
uitableview ×2
date ×1
highlight ×1
iboutlet ×1
iphone ×1
literals ×1
long-integer ×1
nsdate ×1
nsdictionary ×1
overriding ×1
php ×1
time ×1
uiimage ×1
uiimageview ×1
uiview ×1