示例:我添加了一些NSString对象NSMutableArray: @"Foo", @"Bar", @“FooBar".现在在其他地方我再次访问该数组,我想删除@"Foo".所以我创建了一个新的NSString @"Foo",并将其传递给-removeObject:.文档没有说明哪些标准-removeObject有效.我认为它只关注内存地址,所以在这种情况下它什么都不做.那是对的吗?
我确信我忽略了显而易见的事情,因为我有无数的工作按钮......但是......无论出于什么原因,这个都没有合作......
我已经UIButton在UIView子类(DialogView)中添加了一个(Rounded Rect),它是我的视图控制器视图的子视图.此子视图几乎完全在IB中创建.我已将(IBAction)okButtonPressed:(id)senderIB中的按钮连接到Touch Up Inside并在DialogView中创建了相应的方法.但是,当我"触摸"此按钮时,它不会触发该方法.userInteractionEnabled是真正的VC的看法,DialogView 以及对UIButton.
思考可能initWithCoder不得不做一些帧操作或我添加以下成功登录到控制台的东西.
- (id)initWithCoder:(NSCoder *)decoder {
if (self = [super initWithCoder:decoder]) {
NSLog(@"DialogView initWithCoder called");
}
return self;
}
Run Code Online (Sandbox Code Playgroud)
在进一步的探索中,我连接IBOutlet到按钮,然后如果我尝试从视图控制器更改titleLabel,我注意到它被严重截断.首次绘制视图时,在IB中设置的默认文本" Press Me! "显示正常.但如果我改变文字......
self.DialogView.okButton.titleLabel.text = @"Not Working";
Run Code Online (Sandbox Code Playgroud)
......它被截断为"N ......"
如果这是相关的Dunno.大概...
有谁看到我搞砸了什么?
编辑(添加与显示相关的代码UIButton):
从View Controller:
self.DialogView = [[[NSBundle mainBundle] loadNibNamed:@"DialogView" owner:self options:nil] objectAtIndex:0];;
self.DialogView.myVC = self;
self.DialogView.backgroundColor = [UIColor clearColor];
self.DialogView.center = CGPointMake(self.view.frame.size.width / …Run Code Online (Sandbox Code Playgroud) 我试图定义我自己的自定义UICollectionViewCell实现并在一个中使用它UICollectionView.这就是我所做的.
1-我正在使用故事板.
2-我添加了一个UICollectionView到另一个视图,这是故事板上的一个场景.
3-我指出datasource并将delegate该集合添加到场景的控制器中.
4-我在控制器中提供了所需方法的实现.
5-我创建了一个单元格视图.h和.m文件.在.h我做的文件中
@interface HscCellView : UICollectionViewCell
6-我创建了一个新视图,所以我得到了一个新的画布,在右边的相应部分我指定了我的类名(与步骤5中相同),并提供了一个唯一的标识符.
7-在场景的控制器中,我将.h文件中的插座定义为我拖入的集合视图.
@property (nonatomic, strong) IBOutlet UICollectionView *holesCollectionView;
在viewDidLoad我做
[self.holesCollectionView registerClass:[HscCellView class] forCellWithReuseIdentifier:@"cellView"];
Run Code Online (Sandbox Code Playgroud)
请注意,这cellView是我为自定义单元格xib指定的唯一标识符.
8-最后,我实施了
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
HscCellView *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cellView" forIndexPath:indexPath];
return cell;
}
Run Code Online (Sandbox Code Playgroud)
当我启动应用程序时,我得到了一堆单元格视图(9,因为我在numberOfItemsInSection消息上指定了9 )但它们不是我的自定义单元格视图.它们没有尺寸,颜色或标签.我没有看到任何错误.我被卡住了.
一些辅助问题.
我何时使用注册笔尖以及何时注册类名?我已经看到它完成了两种方式,但似乎你总是最终得到一个nib和一个类定义代码,这是真的吗?
在步骤6中,当我在画布中为自定义单元格视图指定唯一ID时,这是否意味着我不需要在该类中注册该类viewDidLoad?
我正在开发一个 iPhone 应用程序。其中,有暂停和恢复相机的要求。所以我使用AVFoundation它而不是使用UIImagePickerController.
我的代码是:
- (void) startup :(BOOL)isFrontCamera
{
if (_session == nil)
{
NSLog(@"Starting up server");
self.isCapturing = NO;
self.isPaused = NO;
_currentFile = 0;
_discont = NO;
// create capture device with video input
_session = [[AVCaptureSession alloc] init];
AVCaptureDevice *cameraDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
if(isFrontCamera)
{
NSArray *videoDevices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo];
AVCaptureDevice *captureDevice = nil;
for (AVCaptureDevice *device in videoDevices)
{
if (device.position == AVCaptureDevicePositionFront)
{
captureDevice = device;
break;
}
}
cameraDevice = …Run Code Online (Sandbox Code Playgroud) 我不确定这是iOS 7的bug还是什么.但是......我无法UIAccessibilityInvertColorsStatusDidChangeNotification上班.
所以,当我开始我的笔尖时,我这样做:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(inverted)
name:UIAccessibilityInvertColorsStatusDidChangeNotification
object:nil];
}
return self;
}
Run Code Online (Sandbox Code Playgroud)
稍后在我的代码中我收到了通知:
- (void)inverted {
if(UIAccessibilityIsInvertColorsEnabled()) {
NSLog(@"setting tintcolor to cyan");
self.view.tintColor = [UIColor cyanColor];
[self tintColorDidChange];
} else {
NSLog(@"setting tintcolor to red");
self.view.tintColor = [UIColor redColor];
[self tintColorDidChange];
}
}
Run Code Online (Sandbox Code Playgroud)
但是,当我的应用程序运行时,我通过主页按钮上的tripple-tap更改了反转颜色模式,应用程序中没有任何反应.不要在控制台上收到消息,不要改变tintColor,不要得到什么.
我在iOS 6和iOS 7上对此进行了测试.我尝试将我的构建目标设置为iOS 6.1而不是4.3,并且也没有修复它.
我尝试添加-(void)inverted;到我的界面,但没有解决它.我尝试在倒置后添加冒号,但也没有修复它,并且文档说这个通知无论如何都没有参数.
显然我做错了什么.什么?提前致谢.
我的观点有两个UITextFields和一个UISwitch.如果用户编辑a textField,然后立即触摸开关(不按返回),则文本在键入时保留,而不是AutoCorrect.
如果我知道textField他们输入了哪些内容,我可以通过调用强制完成自动更正[textField resignFirstResponder].但是用户可能正在键入textField,所以我不知道要拨打哪一个.
我怎么能绕过这个?有没有办法检测哪些textField被使用?还是我没想过的更简单的东西?
MvvmCross从a UIBarButtonItem到a 创建绑定的正确方法是MvxCommand什么?
这对我不起作用 - >
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
this.AddBindings (new Dictionary<object, string> (){
{MyButton, "{'Clicked':{'Path':'MyCommand'}}"}
});
}
Run Code Online (Sandbox Code Playgroud)
我在控制台中没有出现任何错误.我可以通过避免绑定来解决问题,但是你知道,如果所有绑定都是最好的.
我有一个包含四个实体的核心数据模型.该实体Player与其他实体(Player_Scores,Custom_Exercise,Selected_Exercise)具有to-Many关系.
在我的app委托中,我以NSManagedObjectContext,NSManagedObjectModel,NSPersistentStoreCoordinator标准方式创建属性.然后,在一个不同的视图控制器中,我在@interface中为一个NSManagedObjectContext对象和一个newPlayerPlayer实体声明了ivars :
@interface NewProfileViewController()
{
NSManagedObjectContext *context;
Player *newPlayer;
}
Run Code Online (Sandbox Code Playgroud)
然后在一个动作中我有以下代码来创建一个Player实体并输入它的属性,以及一个Player_Scores实体和一个Selected_Exercise实体.我使用的代码成功添加Player_Scores了Player实体的属性.然而,当我尝试Selected_Exercise在循环中添加16个实体并设置它们的属性时,我得到一个很大的" 在前向类对象上找不到属性? "错误.救命!!!!!就像我说的代码是相同的for Selected_Exercise和for Player_Scores.我已经尝试重新启动,删除数据库等.这是我尝试做newEx.exercise=@"blahblahblah";或newEx.suit=@"blahblahblah";UGH 时弹出的编译器错误
以下是该方法的代码:
//1. save a person to database
newPlayer=[NSEntityDescription
insertNewObjectForEntityForName:@"Player"
inManagedObjectContext:context];
newPlayer.name=newentry;
//NSError *error; [context save:&error];
//2. begin making a score card:
Player_Scores *newScoreCard = [NSEntityDescription
insertNewObjectForEntityForName:@"Player_Scores"
inManagedObjectContext:context];
newScoreCard.date_of_game = [NSDate date];
newScoreCard.player=newPlayer; //attach this score card to …Run Code Online (Sandbox Code Playgroud) 我正在使用我正在使用的应用程序UIActivityViewController.
这是我正在使用的代码.
NSString *postText = @"My Text";
NSArray *activityItems = @[postText];
UIActivityViewController *activityController =
[[UIActivityViewController alloc]
initWithActivityItems:activityItems applicationActivities:nil];
activityController.excludedActivityTypes = [NSArray arrayWithObjects:UIActivityTypePrint, UIActivityTypeCopyToPasteboard, UIActivityTypeAssignToContact, UIActivityTypeSaveToCameraRoll, nil];
[self presentViewController:activityController
animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)
这很好用.当我打开Twitter或电子邮件时UIActivityViewController,它显示我想要分享的文本,这很好.
但是,现在我只想在帖子成功或电子邮件发送成功后才在我的数据库中执行某些操作.
我怎样才能做到这一点?
我正在开发一个应用程序,我在其中实现了编辑模式.UICollectionView我正在尝试实现这样的事情:

当我点击编辑按钮时,相机按钮和眼睛按钮应该隐藏,删除和重命名按钮应该如下所示:

编辑完成后,当我点击"完成"按钮时,删除按钮和重命名按钮应该隐藏,相机按钮和眼睛按钮应该再次出现.我试过了,但它给了我一些奇怪的输出.一切正常,除了这个"编辑"按钮功能.任何人都可以建议我解决这个问题.建议将不胜感激.请提供一些建议.提前致谢.
ios ×5
iphone ×5
objective-c ×4
cocoa-touch ×3
avfoundation ×1
core-data ×1
entity ×1
ios6 ×1
mvvmcross ×1
nsarray ×1
relationship ×1
uibutton ×1
uikit ×1
uiswitch ×1
uitextfield ×1
uiview ×1
xamarin.ios ×1
xcode ×1