当我 在IB中设置视图的默认背景(视图用作表格的标题)时,它变为黑色,但是当我在模拟器上运行应用程序时,它具有uitableview背景的默认颜色.
当我将默认颜色设置为黄色时,例如,对于IB和模拟器,它总是为黄色.
为什么IB中的默认背景颜色为黑色,模拟器中的条纹为灰色?
我有默认的初始屏幕,其名称为:Default-568h @ 2x.png,Default-Portrait.png,Default.png,Default @ 2x.png等等,适用于所有类型的设备.
我知道系统会自动为特定设备选择合适的启动画面并显示它.
问题:是否可以知道系统选择了哪个图像?如何将系统选择的适当图像加载到UIimageView.
我试过这个:
UIImageView *splashView=[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, screenWidth, screenHeight)];
splashView.image=[UIImage imageNamed:@"Default.png"];
Run Code Online (Sandbox Code Playgroud)
但它只为所有类型的设备(iPhone 4,5,iPad)加载名称为Default.png的图像.
我需要手动管理吗?我的意思是在识别设备类型后加载适当的图像?
我创建了一个复合组件Box,我想添加到布局中.BoxXML:
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearLayoutForBlock"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" android:background="@drawable/screen_background" android:layout_marginLeft="5dp" android:layout_marginTop="5dp">
<ImageButton
android:id="@+id/imageButtonContent"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_gravity="center_horizontal"
android:scaleType="fitCenter"
android:src="@drawable/beach_bed" android:background="@drawable/buttonbackground" android:clickable="true" android:layout_margin="5dp" android:contentDescription="@string/sample_text"/>
<TextView
android:id="@+id/textViewContent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="@string/sample_text"
android:textColor="@color/deep_blue" android:layout_margin="5dp"/>
</LinearLayout>
</merge>
Run Code Online (Sandbox Code Playgroud)
Box 类:
public class Box extends LinearLayout {
private TextView textContent;
private ImageView imageContent;
public Box(Context context, AttributeSet attrs) {
super(context, attrs);
((Activity)getContext()).getLayoutInflater().inflate(R.layout.box, this);
setupViewItems();
}
private void setupViewItems() {
textContent = (TextView) findViewById(R.id.textViewContent);
imageContent = (ImageView) …Run Code Online (Sandbox Code Playgroud) 我想对 NSURLSession 类进行子类化,但我在初始化时遇到问题。基本上我重写构造函数并在那里初始化常量,authUrl然后调用父 init 方法。
class NSURLAuthSession: NSURLSession {
let authUrl:NSURL;
//Error: Initializer does not override a designated initializer from its superclass
override init(configuration: NSURLSessionConfiguration, delegate: NSURLSessionDelegate?, delegateQueue queue: NSOperationQueue?){
self.authUrl = NSURL.URLWithBaseURLString("http://192.168.10.105:8888/api/v1", pathSegments: ["users", "login"])!
super.init(configuration: configuration, delegate: delegate, delegateQueue: queue)
}
}
Run Code Online (Sandbox Code Playgroud)
从 NSURLSession 的源代码中我发现它有两个初始化器:
public /*not inherited*/ init(configuration: NSURLSessionConfiguration)
public /*not inherited*/ init(configuration: NSURLSessionConfiguration, delegate: NSURLSessionDelegate?, delegateQueue queue: NSOperationQueue?)
Run Code Online (Sandbox Code Playgroud)
我期望“最长”的初始化程序是指定的初始化程序,但事实并非如此。我怀疑指定的初始值设定项init()甚至没有在源代码中指定。如何覆盖初始化程序并设置配置NSURLSessionConfiguration?
menuBar = new JMenuBar();
// File Menu
JMenu fileMenu = new JMenu("File");
menuBar.add(fileMenu);
// File->New
JMenuItem newMenuItem = new JMenuItem("New");
frame.setJMenuBar(menuBar);
newMenuItem.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent arg0) {
btnExample.setText("Clicked");
btnExample.doClick();
//---------->SOME HOW TO EXECUTE btnExample<---------//
}
});
fileMenu.add(newMenuItem);
final JButton btnExample = new JButton("SD");
frame.getContentPane().add(btnExample, "cell 4 0,growx,aligny top");
btnExample.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent arg0) {
spinnerForVar.setValue(4);//default value for spinner
spinnerForFunc.setValue(4);//default value for spinner
...
}
});
Run Code Online (Sandbox Code Playgroud)
你好!我希望有一个人可以帮助我.这就是问题:我有菜单项"新建"并有按钮btnExample.我想要以下内容:当我点击"文件 - >新建"时,它执行btnExample.我的代码只能更改按钮标题并显示单击的视觉效果.但是我怎么能真正执行呢?