小编cha*_*yWu的帖子

Objective-C:如何从子类访问父私有属性?

//Super class .h file

@interface MySuperClass : NSObject

@end

//Super class .m file

@interface MySuperClass ()

@property (nonatomic, strong) UITextField *emailField; 

@end

@implementation MySuperClass

-(void)accessMyEmailField {

   NSLog(@"My super email: %@", self.emailField.text);

}

@end


// ********** my subclass *******

//Subclass .h file

@interface MySubClass : MySuperClass

@end

//SubClass .m file

@interface MySubClass ()

@end

@implementation MySubClass

-(void)myEmail {

   NSLog(@"My subclass email: %@", self.emailField.text);

}

-(void)setMyEmailFromSubclass{

   self.emailField.Text = @"email@gmail.com"

}

@end
Run Code Online (Sandbox Code Playgroud)
  1. 我如何访问emailField -(void)myEmail method.
  2. 如何在子类中设置电子邮件-(void)setMyEmailFromSubclass; ,并在超类中访问它accessMyEmailField

iphone objective-c ios ios6 ios7

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

为什么这两个NSString指针是一样的?

当我allocinit两个NSString变量比较它们的指针时,它们是相同的.这是一个显示以下内容的片段:

NSString *s1 = [[NSString alloc] initWithString:@"hello world"];
NSString *s2 = [[NSString alloc] initWithString:@"hello world"];

if (s1 == s2) {
    NSLog(@"==");
}else {
    NSLog(@"!=");
}
Run Code Online (Sandbox Code Playgroud)

为什么s1s2相同?

cocoa objective-c nsstring

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

在galaxy选项卡上启动时,xml Android颜色文件上的int无效

当我尝试在带有android 4.1.2的Galaxy Tab上启动它时,我的Android应用程序崩溃了.错误是:

09-26 21:06:10.293: E/AndroidRuntime(9596): Caused by: java.lang.NumberFormatException: Invalid int: "res/color/tw_primary_text_holo_dark.xml"
Run Code Online (Sandbox Code Playgroud)

此错误不会出现在Android 4.2.2的galaxy s4上,也不会出现在Android 4.1.1的模拟器(手机或标签屏幕大小)上.

我试图找到这个tw_primary_text_holo_dark.xml文件,我找不到它.但是在primary_text_holo_dark中显然存在.

你知道为什么这只出现在我的标签上吗?

android

8
推荐指数
2
解决办法
2389
查看次数

将默认的interactivePopGestureRecognizer扩展到屏幕边缘以外?

我有一个UIViewController被推入导航堆栈.我想扩展标准的iOS7交互式平移手势,将此视图控制器弹出超出默认UIRectEdgeLeft边界,以便用户可以通过从视图中的任何位置进行平移来启动交互式后退操作.

我已经尝试过滚动我自己的交互式视图控制器转换,但完全复制默认的好视差处理是很麻烦的interactivePopGestureRecognizer.例如,fromViewController隐藏导航栏,而toViewController显示它 - 在自定义交互式转换中不易处理的东西,但在默认操作中是无缝的.

因此,我想将默认操作扩展到更大的平移手势区域,但API似乎不支持简单地替换手势.

任何创意建议?

objective-c ios ios7

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

如何堆叠UICollectionView部分

我最初尝试这样做,两个UICollectionViews堆叠在一起.然而,将其扩展到正确是噩梦Auto-layout(我是一个新手iOS开发人员,所以这更像是对我的技能的批评而不是Auto-layout).我想将两部分UICollectionView单元格堆叠在一起,如下所示:

             +----------------------+
             |+-Section 0---------->|
             | +-------+  +-------+ |
             | |       |  |       | |
             | |       |  |       | |
             | |Cell 0 |  |Cell 1 |+->
             | |       |  |       | |
             | |       |  |       | |
             | +-------+  +-------+ |
             +--Section 1---------->|
             | +-------+  +-------+ |
             | |       |  |       | |
             | |       |  |       | |
             | |       |  |       | |
             | |Cell 0 |  |Cell …
Run Code Online (Sandbox Code Playgroud)

cocoa-touch ios uicollectionview uicollectionviewlayout ios7

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

为什么将MBProgressHUD的隐藏设置为YES,但isHidden方法是否为NO?

我正在使用MBProgressHUD视图来显示我从Internet下载内容时的加载状态.下载完成后,我调用hide方法隐藏视图.我想通过检查视图的隐藏,即isHidden方法,使用计时器判断下载是否完成.但是当我将视图的hide设置为YES时,然后检查isHidden方法,它返回NO.我不知道为什么这个视图会这样?

一些片段如下:

MBProgressHUD   *HUD; // instance variable
Run Code Online (Sandbox Code Playgroud)

在下载完成的方法中:

[HUD hide:YES];
NSLog(@"HUD isHidden: %@",[HUD isHidden] ? @"YES" : @"NO");
Run Code Online (Sandbox Code Playgroud)

调用该方法时,输出为NO.

iphone objective-c uiview ios mbprogresshud

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

为什么GCDAsyncUdpSocket在广播模式下一段时间后无法发送/接收数据包?

我正在使用GCDAsyncUdpSocket在我的应用程序中编写UDP套接字.场景是这样的:当用户点击按钮时,它将在LAN中发送广播数据包然后收听响应,LAN中有一个服务器将响应一个UDP数据包.当应用收到响应时,它会执行某些操作.

我设定GCDAsyncUdpSocket如下:

- (void)setupSocket
{
    _udpSocket = [[GCDAsyncUdpSocket alloc] initWithDelegate:self delegateQueue:dispatch_get_main_queue()];

    NSError *error = nil;

    if (![_udpSocket bindToPort:18686 error:&error]) {
        NSLog(@"Error binding: %@",error);
        return;
    }

    if (![_udpSocket beginReceiving:&error]) {
        NSLog(@"Error receiving: %@",error);
        return;
    }

    if (![_udpSocket enableBroadcast:YES error:&error]) {
        NSLog(@"Error enableBroadcast: %@",error);
        return;
    } 
}
Run Code Online (Sandbox Code Playgroud)

然后我按钮按钮动作发送如下:

NSString *host = @"255.255.255.255";
int port = 8585;
NSString *msg = @"Hello from iOS";
NSData *data = [msg dataUsingEncoding:NSUTF8StringEncoding];
[_udpSocket sendData:data toHost:host port:port withTimeout:-1 tag:0]; 
Run Code Online (Sandbox Code Playgroud)

- (void)udpSocket:(GCDAsyncUdpSocket *)sock     didReceiveData:(NSData …
Run Code Online (Sandbox Code Playgroud)

udp objective-c broadcast ios gcdasyncsocket

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

Spring Boot 与 websphere 配置类不工作

使用 springboot tomcat 运行应用程序时出现以下错误。以下错误消息不断重复。请帮忙。

2015-09-22 03:37:09.477 ERROR 20112 --- [ main] ciwnaming.java.javaURLContextFactory : NMSV0307E: 使用了 java: URL 名称,但命名未配置为处理 java: URL 名称。可能的原因是用户错误地尝试在非 J2EE 客户端或服务器环境中指定 java: URL 名称。抛出配置异常。

依赖关系

<dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>log4j-over-slf4j</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.aredis</groupId>
            <artifactId>aredis</artifactId>
            <version>1.4</version>

        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <!-- <version>1.2.16</version> -->

        </dependency>
        <dependency>
            <groupId>net.sf.joesnmp</groupId>
            <artifactId>joesnmp</artifactId>
            <version>0.3.4</version>

        </dependency>
        <dependency>
                <groupId>com.ibm.ws.admin</groupId>  
                <artifactId>adminClient</artifactId>  
                <version>8.5.0</version>  
        </dependency>
        <dependency>
            <groupId>com.ibm.ws.runtime</groupId>
            <artifactId>ibmRuntime</artifactId>
            <version>1.0</version>
        </dependency>

        <dependency>
            <groupId>com.ibm.websphere</groupId>
            <artifactId>ibmorb</artifactId>
            <version>8.5</version>
        </dependency>

        <dependency>
            <groupId>com.ibm.websphere</groupId>
            <artifactId>ibmorbapi</artifactId>
            <version>8.5</version>
        </dependency>

        <dependency>
            <groupId>com.ibm.websphere</groupId>
            <artifactId>orb</artifactId>
            <version>8.5</version>
        </dependency> …
Run Code Online (Sandbox Code Playgroud)

java websphere spring spring-boot

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

设置 html 页面的最小高度

当您尝试调整窗口大小时,我正在使用min-widthmin-height设置网页的最小宽度和高度。请参阅片段打击。

我也将 html 放入了dropbox中。min-width 在 chrome 中有效,在 IE 中无效,min-height 根本不起作用。我的代码有什么问题吗?任何帮助,将不胜感激。

body {
  min-width: 330px; <!-- This only works in chrome not work in IE -->
  min-height: 400px; <!-- This doesn't work at all. -->
}
fieldset {
  border:5px;
}
select {
  width: 100px;
}
input {
  width: 195px;
}
input, select {
  height: 30px;
  box-sizing: border-box;
  -moz-box-sizing: border-box;
  -webkit-box-sizing: border-box;
}
table {
  width: 300px;
}
table, th, td {
  border: 1px solid grey; …
Run Code Online (Sandbox Code Playgroud)

html javascript css jquery

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

在scrapy中提取类名

我试图从 trustpilot.com 上刮掉评级。

是否可以使用scrapy提取类名?我正在尝试刮取由五个单独图像组成的评级,但这些图像位于具有评级名称的类中,例如,如果评级为 2 则开始:

<div class="star-rating count-2 size-medium clearfix">...
Run Code Online (Sandbox Code Playgroud)

如果是 3 星,则:

<div class="star-rating count-3 size-medium clearfix">...
Run Code Online (Sandbox Code Playgroud)

那么有没有一种方法可以抓取类count-2count-3假设一个选择器.css('.star-rating')

python css-selectors scrapy web-scraping

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