I integrate the iCarousel into my application.It is working fine.But my requirement is to display the two buttons in single view and specific actions for these two buttons.I display the buttons as
- (UIView *) carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view{
UIView *sampleView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 250, 300)];
sampleView.backgroundColor=[UIColor whiteColor];
UIButton* btntrans=[UIButton buttonWithType:UIButtonTypeCustom];
[btntrans setFrame:CGRectMake(45, 40, 105, 50)];
[btntrans setBackgroundColor:[UIColor clearColor]];
btntrans.titleLabel.font = [UIFont fontWithName:#"Arial-BoldMT" size:15];
[btntrans setTitle:#"" forState:UIControlStateNormal];
[btntrans setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[sampleView addSubview:btntrans];
UIButton* btntrans1=[UIButton buttonWithType:UIButtonTypeCustom];
[btntrans1 setFrame:CGRectMake(45, 90, 105, 50)];
[btntrans1 setBackgroundColor:[UIColor clearColor]];
btntrans1.titleLabel.font = [UIFont fontWithName:#"Arial-BoldMT" size:15];
[btntrans1 setTitle:#"" forState:UIControlStateNormal];
[btntrans1 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[sampleView addSubview:btntrans1];
return sampleView;
}
we can use
-(void)carousel:(iCarousel *)carousel didSelectItemAtIndex:(NSInteger)index
{
NSLog(#"ITEM SELECTED");
}
for whole view selection.but How to set the two specific actions for these two buttons?
Thanks in advance.
Bind the button action to your view controller when you create the item view, then use indexForViewOrSubview: method of carousel in your action method to work out which button was pressed.
If you are using a nib to create your views, take a look at the controls example included with the iCarousel example projects for how to do this.
Why don't you try this:
[btntrans addTarget:self
action:#selector(first_action)
forControlEvents:UIControlEventTouchUpInside];
Similarly,
[btntrans1 addTarget:self
action:#selector(second_action)
forControlEvents:UIControlEventTouchUpInside];
Correspondingly in the events:
- (void)first_action:(id)sender{
//This will get you the index of the selected view
NSInteger index = [self.carousel indexOfItemViewOrSubview:sender];
.......
//Do whatever you feel like
}
Related
I just updated to Xcode 9 and run to an iOS11 simulator. My custom view for the navaagation bar title is shifted down.
This code was working before i updated; it was vertically centered before
companyCountryView = CompanyNameView(frame: CGRect(x: 0, y: 0, width: Utils.getScreenWidth() - 150, height: 35))
companyCountryView.companyLbl.text = ""
companyCountryView.countryLbl.text = ""
self.navigationItem.titleView = companyCountryView
Even though I change values for y and height, no effect at all.
It seems the width value i used does not do any effect too.
I have solved it! You need to override the intrinsicContentSize in your custom view class and put the size of the view there:
class CustomView: UIView {
override var intrinsicContentSize: CGSize {
return CGSize(width: Utils.getScreenWidth() - 150.0, height: 35.0)
}
}
I dynamically create several panels and add the into an accordion menu. For each of this panels I want to add an ext.menu.Menu component but when I try do that the menu is not visible and also not present in the DOM. I also create a few menu items which I add to the menu.
for (var i = 0; i < store.totalCount; ++i){
var rec = store.getAt(i);
var panelItem = new Ext.panel.Panel({
title: (Ext.Date.format(rec.data.dateBorn, 'd-m-Y')) + " " + rec.data.name,
value:rec.data.VALUE_FIELD,
});
panel.add(panelItem);
var userMenu = new Ext.menu.Menu({
width: 120,
height: 70,
className:"menu"
});
panelItem.add(userMenu);
}
If I create a menu item and add to the panel it is shown, but I want to have them in a menu, What is wrong here?
Menu is by default floating component. To configure component as floating or not floating you can use floating configuration property.
So if you want to display menu directly in your panel the configuration of menu should be:
var userMenu = new Ext.menu.Menu({
width: 120,
height: 70,
className:"menu",
floating: false,
});
I try this code for set the alpha value in button image:
UIImageView *imageTopView = [[UIImageView alloc] initWithImage:
[UIImage imageNamed:#"Top_80.png"]];
imageTopView.alpha = 0.5;
topBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[topBtn addTarget:self action:#selector(btnRotatingObj:)
forControlEvents:UIControlEventTouchUpInside];
[topBtn setImage: imageTopView.image forState:UIControlStateNormal];
[topBtn setTitle:#"TOP" forState:UIControlStateNormal];
[self.view addSubview:topBtn];
its not working.....
You are setting the image of the button with the image of your image view. Your image view has an alpha of 0.5, but of course not your image.
Instead, add the image view as a subview of your button:
[topBtn addSubView:imageTopView];
I have a panel with a "form" layout, containing several buttons. now I want to enable this panel resize according to window resizing. How can I get this done?
thanks.
Ext.EventManager.onWindowResize(function(w, h){
panel.doComponentLayout();
});
Assuming you have a Panel named 'panel' with some automatic sizing built in (e.g. height: "100%"). Otherwise, the new width and height of the window are passed into the anonymous function passed to onWindowResize().
As wrote #deniztt you should subscribe to EventManager class onWindows Resize Event.
It can be something like this:
Ext.EventManager.onWindowResize(function () {
var width = Ext.getBody().getViewSize().width - 160;
var height = Ext.getBody().getViewSize().height - 140;
panel.setSize(width, height);
});
Where panel is reference to your panel
You can read about it here.
You can make the panel resizable by setting the 'resizable' config option, see the docs for the various options: http://dev.sencha.com/deploy/ext-4.0.0/docs/api/Ext.panel.Panel.html.
As far as how the form components interact you'll need to set anchor's if you want to use a form layout or switch to an hbox/vbox type of set-up with various flex settings.
You can set the size for window and set the child panel's autoHeight and autoWidth attributes true.
Another way is catching the resize event of the window and resize the child panel according to the new size values.
Thanks to Gegory and Joseph for the EventManager solution. I've done some minor changes to this solution, replacing the getBody() with a DIV and setting an initial width/height of my chart (or any other component):
<div id="chart" style="overflow: hidden; position:absolute; width:100%; height:90%;"></div>
....
Ext.onReady(function() {
var renderDiv = Ext.get('chart_div');
var chart = Ext.create('Ext.chart.Chart', {
renderTo: renderDiv,
width: renderDiv.getWidth(),
height: renderDiv.getHeight() - 50,
...
});
Ext.EventManager.onWindowResize(function () {
var height = renderDiv.getHeight() -50;
var width = renderDiv.getWidth();
chart.setSize(width, height);
});
});
autoWidth and autoHeight don't seem to work for me (Ext-JS 4.2.1).
I have the following code:
void Test()
{
currentImage.Source = GetBitmap();
RenderTargetBitmap rtb = new RenderTargetBitmap(100, 100, 96.0, 96.0, PixelFormats.Default);
rtb.Render(currentImage);
}
This code is supposed to render currentImage, which is an Image control in my xaml to a RenderTargetBitmap.
It doesn't work, rtb returns a blank image, the problem is currentImage didn't render itself yet and so this behavior is expected, I think...
To workaround this problem, I wrote this code:
void Test()
{
currentImage.Source = GetBitmap();
this.Dispatcher.BeginInvoke((Action)delegate()
{
RenderTargetBitmap rtb = new RenderTargetBitmap(100, 100, 96.0, 96.0, PixelFormats.Default);
rtb.Render(currentImage);
}, System.Windows.Threading.DispatcherPriority.Render, null);
}
Basically, I wait for currentImage to be rendered and then I can get it properly rendered to my RenderTargetBitmap.
Is there any way to make it work without using this workaround? Force the Image control to render in memory maybe?
thanks!
use a ViewBox to render in memory
Grid grid = new System.Windows.Controls.Grid() { Background = Brushes.Blue, Width = 200, Height = 200 };
Viewbox viewbox = new Viewbox();
viewbox.Child = grid; //control to render
viewbox.Measure(new System.Windows.Size(200, 200));
viewbox.Arrange(new Rect(0, 0, 200, 200));
viewbox.UpdateLayout();
RenderTargetBitmap render = new RenderTargetBitmap(200, 200, 150, 150, PixelFormats.Pbgra32);
render.Render(viewbox);
I think this is a BETTER answer . The viewbox didn't work completely as expected, and it turned out to be an unnecessary overhead.
Here is a copy of that answer (instead of just link)
You need to force a render of the item, or wait for the item to be rendered. You can then use the ActualHeight and ActualWidth properties.
To force a render:
MenuItem item = new MenuItem();
item.Header = "bling";
item.Icon = someIcon;
//Force render
item.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity));
item.Arrange(new Rect(item.DesiredSize));
In this example the MenuItem has not been given an explicit height or width. However, forcing the render will render it taking the supplied header text and icon into consideration.