有人可以解释代表如何UIAlertView工作?是自动调用还是必须调用它?例如:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
我需要获取颜色的字符串值.换句话说,我想#ffffffff从像<color name="color">#ffffffff</color>字符串格式的颜色资源中拉出来.有没有办法做到这一点?
如何在java中的笔记本电脑触控板上检测到双指滚动?我一直在搜索谷歌和这里,但在使用触控板滚动时找不到任何内容,更不用说如何倾听它了.任何帮助将不胜感激.谢谢.
我试图在objective-c中编写我的第一个类,我想在类的方法中传递NSString对象作为参数,但是我得到一个错误,说"不能使用对象作为方法的参数".所以我的问题是如何将字符串作为参数传递给方法?这是我的代码我试图开始工作:
#import <Foundation/Foundation.h>
@interface Car
{
NSString *color;
NSString *make;
int year;
}
- (void) print;
- (void) setColor: (NSString) c;
- (void) setMake: (NSString) m;
- (void) setYear: (int) y;
@end
@implementation Car
- (void) print
{
NSLog(@"The $d Ford %@ is $@.", year, make, color);
}
- (void) setColor: (NSString) c
{
color=c;
}
- (void) setMake: (NSString) m
{
make=m;
}
- (void) setYear: (int) y
{
year=y;
}
@end
int main (int argc, const char * …Run Code Online (Sandbox Code Playgroud) 当设备的方向改变时,我将如何加载新的xib?即,当设备变为横向时加载横向导向的xib,反之亦然,纵向加载.以及如何自动检测方向变化并从那里进行调整?
我已经看到并使用了javascript代码,它们都有和省略';' 从陈述结束.它们在某些情况下是否需要而在其他情况下不需要 如果是这样,你可以提供一些例子,如果不是通用标准,那么使用';' 还是不......那个问题是什么?
我希望获得触摸的位置,最好对应于屏幕的像素.我是Objective-c和cocoa的新手,并且无法在网上找到关于此的任何内容,所以我不确定是否有办法做到这一点.任何想法或方向看哪里都会有所帮助.谢谢.
所以我想要做的是当触摸任何给定的UIView,并在窗口周围移动时,将其带到前面并位于所有其他层的顶部.有没有办法以编程方式执行此操作?
任何人都可以告诉我为什么这行会抛出不兼容的类型错误?
UIDeviceOrientation *orientation = [UIDevice currentDevice].orientation;
Run Code Online (Sandbox Code Playgroud) 我不断得到一个Unable to instantiate activity ComponentInfo... Caused by a NullPointerException at findViewById,我不知道它为什么扔它.我在我的设备中正确设置了我的元素ID,main.xml并且我已经尝试在每个线周围注释,看看哪条线有问题,但要让它运行w/o任何力量关闭我必须注释掉所有的功能程序.这是我的活动:
package fsg.dev.test.checkboxtest;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.SeekBar;
public class checkBoxTest extends Activity {
private CheckBox checkbox = (CheckBox) findViewById(R.id.checkbox);
//private SeekBar seekbar = (SeekBar) findViewById(R.id.seekbar);
private View view = (View) findViewById(R.id.background);
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
checkbox.setOnCheckedChangeListener(new OnCheckedChangeListener(){
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked){
changeColor();
}
});
}
private void changeColor(){
if(checkbox.isChecked()){
view.setBackgroundColor(R.color.Blue); …Run Code Online (Sandbox Code Playgroud) android nullpointerexception android-manifest android-layout
我有两个活动,第一个是正确生成,但第二个不是.只显示xml文件中的第一个元素.这是我的xml文件:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/alternateActivity"
android:shadowColor="@color/shadowColor"></TextView>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/oldActivityButton"
android:text="@string/oldActivityButton"></Button>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/changeText"
android:text="@string/changeTextButton"></Button>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/originalText"
android:id="@+id/textToChange"></TextView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
这是我的活动对应:
package fsg.dev.activitytest;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
public class newActivity extends Activity {
private Button oldActivityButton;
private Button changeText;
private TextView textToChange;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.alternate);
oldActivityButton = (Button) findViewById(R.id.oldActivityButton);
changeText = (Button) findViewById(R.id.changeText);
textToChange = (TextView) findViewById(R.id.textToChange);
oldActivityButton.setOnClickListener(new OnClickListener(){ …Run Code Online (Sandbox Code Playgroud) -(void)processGlyph:(int)glyphOne withGlyph:(int)glyphTwo
{
answer = glyphOne + glyphTwo;
NSString *tempText = [[NSString alloc] init];
tempText = [NSString stringWithFormat:@"%i",answer];
[self dispatchText:tempText];
[tempText release];
}
-(void)checkReadyToProcess
{
if (count >= 2) {
[self processGlyph:firstGlyph withGlyph:secondGlyph];
}
}
-(void)dispatchText:(NSString *) theText
{
answerText.text = theText;
}
Run Code Online (Sandbox Code Playgroud) objective-c ×7
cocoa-touch ×5
android ×3
iphone ×2
colors ×1
java ×1
javascript ×1
layout ×1
listener ×1
scroll ×1
string ×1
trackpad ×1
uikit ×1
xml ×1