小编And*_*ers的帖子

设置UILABEL的初始值

我正在尝试创建一个简单的测验应用程序(我是初学者),当我启动应用程序时,我想要一个UILabel来显示第一个问题(一系列问题).我在设置初始值时遇到了一些麻烦.

我做了几次尝试,成功了.我的QuizAppDelegate.h文件我声明我的UILabel是这样的:

 IBOutlet UILabel * questionField;
Run Code Online (Sandbox Code Playgroud)

在我的主.m文件中,我尝试了以下内容:

- (id)init {

    [super init];

    questions = [[NSMutableArray alloc] init];

    // Not working
    questionField = [[UILabel alloc] init];
    [questionField setText:@"Hello"];

    // Working
    NSLog(@"Hello");

    [self defaultQuestions];
    // [self showQuestion];

    return self;
}
Run Code Online (Sandbox Code Playgroud)

我尝试过的另一件事是QuizAppDelegate中的以下内容:

@property (nonatomic, retain) IBOutlet UILabel *questionField;

- (void)changeTitle:(NSString *)toName;
Run Code Online (Sandbox Code Playgroud)

在.m文件中:

@synthesize questionField;

- (id)init {

    [super init];

    questions = [[NSMutableArray alloc] init];

    // Not working
    [self changeTitle:@"Hello"];

    // Working
    NSLog(@"Hello");

    [self defaultQuestions];
    // [self showQuestion];

    return self;
}

-(void)changeTitle:(NSString *)toName { …
Run Code Online (Sandbox Code Playgroud)

objective-c ios

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

为什么不调用我的NSView委托方法?

我正在开发我的第一个Mac应用程序,我在使用NSView及其委托方法时遇到了一些麻烦.我有一个应该响应鼠标事件的NSViewController,即mouseDown.这不起作用,而是我创建了一个自定义的NSView子类,如下所示:

// Delegate method
@protocol CanvasViewDelegate
    - (void)mouseDown:(NSEvent *)event;
@end

@interface CanvasView : NSView
{
    id delegate;
}

@property (nonatomic, strong) id delegate;
@end

@implementation CanvasView
@synthesize delegate;

- (void)mouseDown:(NSEvent *)event
{
    [delegate mouseDown:event];
}
Run Code Online (Sandbox Code Playgroud)

应该充当NSView委托的NSViewController相关部分如下所示:

#import "CanvasView.h"

@interface PaintViewController : NSViewController <CanvasViewDelegate>
{
    CanvasView *canvasView;
}

@property (strong) IBOutlet CanvasView *canvasView;

@end 

@synthesize canvasView;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
    {
        self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
        if (self) {
        // Initialization code here.
        canvasView = [[CanvasView alloc] init];
        canvasView.delegate = …
Run Code Online (Sandbox Code Playgroud)

macos cocoa delegates nsview

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

Removed pod还删除了相关的Framework

我有一个看起来像这样的podfile:

platform :ios, '6.0'
xcodeproj 'NetApp.xcodeproj'

pod 'AFNetworking'
pod 'TTTAttributedLabel'
pod  '[x]'
Run Code Online (Sandbox Code Playgroud)

决定免去pod '[x]'从我podfile,我然后跑pod installpod update.但现在我收到以下警告:

SystemConfiguration framework not found in project, or not included in precompiled header.  Network reachability functionality will not be available.
MobileCoreServices framework not found in project, or not included in precompiled header. Automatic MIME type detection when uploading files in multipart requests will not be available.
Run Code Online (Sandbox Code Playgroud)

我试图在Pods和my中手动添加框架Xcode-projplace.但它似乎不起作用,并且缺少一些功能.

我该如何解决这个问题?是否有可能以某种方式重新安装所有pod?

更新

似乎并不是因为删除了导致它的Pod.做了一个git revert.但当我跑 pod update(更新AFNetworking …

ios xcode4 cocoapods

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

Rails 4 - 未初始化的常量SessionController

我正在开发一个Rails应用程序,其中我有一个Session控制器,其中包含以下方法:

def destroy
  session[:user_id] = nil
  redirect_to root_path, notice: "Utloggad"
end
Run Code Online (Sandbox Code Playgroud)

在我的路线文件中,我有以下路线:

controller :session do
  get 'login' => :new
  post 'login' => :create
  delete 'logout' => :destroy
end
Run Code Online (Sandbox Code Playgroud)

我的观点看起来像这样:

= link_to "Log out", logout_path, method: :delete, :class => "small"
Run Code Online (Sandbox Code Playgroud)

当我按下链接时,我收到以下错误:uninitialized constant SessionController.我怎么解决这个问题?

ruby routes ruby-on-rails

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

Rails 4.1 - 思考 - 狮身人面像协会无法正常工作

我有一个包含两个模型的Rails应用程序,Post并且User,我正在使用Sphinxthinking-sphinxgem来启用搜索.每个帖子属于一个用户,belongs_to每个帖子都有很多帖子.当我搜索帖子时,我也希望能够通过创建帖子的用户名进行搜索.我的帖子索引如下:

ThinkingSphinx::Index.define :post, :with => :active_record do
  indexes name, :sortable => true
  indexes post_description
  indexes user.name, as: :post_user

  has user_id, team_id, created_at, updated_at
end
Run Code Online (Sandbox Code Playgroud)

我的用户索引如下所示:

ThinkingSphinx::Index.define :user, :with => :active_record do
  indexes name, :sortable => true
  indexes email
  indexes about

  has team_id, created_at, updated_at
end
Run Code Online (Sandbox Code Playgroud)

当我运行:rake ts:index,我收到以下错误:

rake aborted!
NoMethodError: undefined method `_reflect_on_association' for #<Class:0x007fd417610c90>
Run Code Online (Sandbox Code Playgroud)

关于如何解决它的任何想法?

更新

indexes user.name, as: :post_user当我没有任何错误时,我很确定这条线是导致他的.但该协会仍然无效..

ruby sphinx ruby-on-rails thinking-sphinx

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